Inheritance and Method Overloading
What is the output when the main method is executed?
class Base {
public void test(int a) {
System.out.print("Base");
}
}
class Derived extends Base {
public void test(double a) {
System.out.print("Derived");
}
}
public class Test {
public static void main(String[] args) {
Base b = new Derived();
b.test(5);
}
}
A
Compilation Error
B
BaseDerived
C
Derived
D
Base
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE