Static Method Hiding
What is printed when the main() method of class Child is executed?
class Parent {
public static void show() {
System.out.println("Parent");
}
}
class Child extends Parent {
public static void show() {
System.out.println("Child");
}
public static void main(String[] args) {
Parent p = new Child();
p.show();
}
}
A
Parent
B
Child
C
Compilation Error
D
Runtime Error
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE