Multiple choice technology programming languages

class A2{ static void doprint(){ System.out.println("A2"); } } class B2 extends A2{ static void doprint(){ System.out.println("B2"); } } public class StaticTest { public static void main(String[] args) { A2 a = new B2(); a.doprint(); } }

  1. A2

  2. B2

  3. Compilation fails

  4. runtime error

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Static methods in Java are resolved at compile-time based on the declared reference type, not the runtime object type. Since reference variable a is of type A2, calling a.doprint() executes A2's static method, not the subclass B2's method.