Method Overriding and Super Keyword
What is printed when the main method of the Child class is executed?
public class Parent {
public String shout() { return "Hello"; }
}
public class Child extends Parent {
public String shout() { return super.shout() + " World"; }
public static void main(String[] args) {
System.out.println(new Child().shout());
}
}
A
Hello World
B
World
C
Hello
D
HelloHello
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE