Given:
What is the output?
Given:
What is the output?
The output is that the compilation fails. In Java, method overloading is allowed with different parameter types, but method signatures must differ in more than just return type. Since both methods in the 'Test' class have the same name and no parameters, their signatures are identical, which causes a compilation error due to method ambiguity.
Tested: C.
it is possible to have different return type for a overriding method in child class, but child’s return type should has co-variant type based on Liskov substitution principle.
No compile, cannot exist two method with same SIGNATURE (name , parameter number and type), and return two diferent types.
C is correct Duplicate method getVal() in type Test
C is the answer as same name and same signature is not allowed in Java even if they have different return types