Polymorphism and Method Overloading
What is printed when the following code segment is executed?
class Base {
public void method(Number n) {
System.out.println("Base Number");
}
}
class Derived extends Base {
public void method(Integer n) {
System.out.println("Derived Integer");
}
}
public class Main {
public static void main(String[] args) {
Base obj = new Derived();
obj.method(10);
}
}
A
Base Number
B
Derived Integer
C
Compilation Error
D
Base NumberDerived Integer
Question Leaderboard
Not enough data yet to show leaderboard.
