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