You cannot do that normally. You have to have return types declared and the value being returned should be of the declared type or a subtype.
There are other ways to do that - declaring the method return type as Object and returning anything you want, but this is NOT the way to go.
First, a very simple question: Why do you want to return different types based on different input conditions? Generally this should be because you are doing two different things in the method based on the type you are passing. This is the place to look at. Have different methods for the different types and call one of them based on the type at hand. (And you can go further using factory patterns...)