public class A {
public static String name() { return "A"; }
}
public class B extends A {
public static String name() { return "B"; }
}
A x = new B();
System.out.println(x.name());What is printed?
- A
Compile-time error
- B
B
- Ccheck_circle
A
- D
AB
Explanation
Static methods are NOT subject to dynamic dispatch. They are resolved by the declared (compile-time) type, which is A.