Inheritance and Method Overloading
When b.foo(5) is called in the main method, what is printed?
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
A
B
Compilation Error due to ambiguous call
C
No output
D
B
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE