My friend had bought minecraft but he had bought at the end of the pocket instead of java version he can "buy back" the pocket version again and then buy the right version with the money? Please reply
No.
Nope, do not go. Bad luck. That's why you read the purchase confirmation before, so as not to catch the Bedrock Edition.
He should go in his order history from the Microsoft Store, if he has bought the game about it and then there's the option "request return", if he is lucky.
He should then specify that he would like the money to be transferred to his Microsoft account as a credit, if that is possible.
Additional: