I declared two functions in a class like this:
Only Type A and Type B are defined in my class
a. It compile successfully.
b. When I call function like this: or It calls the Type B implementation.
c. When I call function like this: It shows me a compile time error.
All three types are defined in my class -> I get a compile time error saying that func2 is already defined.
Firstly, why is this difference in behavior observed between Case 1 and Case 2? When we had two functions(Type A and Type B) where the only difference was the return type, it compiled. However, when we added Type 3, again with a different return type, it didn't compile?
Secondly, between Case1.b and Case1.c, on what basis does Java decide when to call which implementation of the function (between Type A and Type B)