How powerful is UE4's 2d game egine?

You should read about Paper2D

I think Unity is more fleshed out for 2d games, but I think Unreal Engine is a perfectly fine choice as well. Like a lot of things, including 3D games, it’s likely not limited by much besides your own personal skill.

You can’t use Java, but you don’t have to use C++ :). You can use blueprints. They are capable of so much, especially in a 2d game which will always be relatively simpler compared to a 3D game.