public class A {
public String show(A o) { return "A-A"; }
}
public class B extends A { }
A x = new A();
B y = new B();
System.out.println(x.show(y));What is printed?
- A
B-A
- B
Compile-time error
- C
B-B
- Dcheck_circle
A-A
Explanation
show(A) accepts B (upcast). Calls A.show(A) returning "A-A".