Inheritance and Method Overloading
Consider the following class declarations. What is the output when the main method of the Test class is executed?
class A {
public void foo(int x) {
System.out.println("A");
}
}
class B extends A {
public void foo(double x) {
System.out.println("B");
}
}
public class Test {
public static void main(String[] args) {
B b = new B();
b.foo(5);
}
}
A
No output
B
B
C
Compilation Error due to ambiguous call
D
A
Question Leaderboard
Not enough data yet to show leaderboard.
