public class A {
public String greet() { return "hello"; }
}
public class B extends A {
public String greet() { return super.greet() + " world"; }
}
// Usage:
B b = new B();
System.out.print(b.greet());What is printed?
- A
world
- B
hello hello world
- Ccheck_circle
hello world
- D
Stack overflow
Explanation
super.greet() calls A's greet returning "hello". B's greet appends " world", so "hello world" is printed.