What is the result of the following code compilation and execution?

class A {
    private static void test1() { 
        System.out.println("A.test1");
    } 
    
    static void test2() {
        test1();
    } 
} 

public class B extends A { 
    void test1() {
        System.out.println("B.test1");
    } 
    static void test2() {
        super.test2();
    } 
    public static void main(String[] args) { 
        A a = new B(); a.test2(); 
    }
}
Explanation
super keyword cannot be used in static methods.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback