public class A {
public String hello() { return "Hi from A"; }
}
public class B extends A {
public String hello() { return super.hello() + " and B"; }
}
System.out.println(new B().hello());What is printed?
- A
Stack overflow error
- B
and B
- Ccheck_circle
Hi from A and B
- D
Hi from A
Explanation
<code>super.hello()</code> calls A's version, returning "Hi from A". Then " and B" is appended.