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
B
HelloHello
C
World
D
Hello World
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE