What happens as a result of compiling and running this code?

class Class1 {
    Class1(int i) {
        System.out.println("Class1(int)");
    }
}

public class Class2 extends Class1 {
    Class2(double d) {              // 1
 this((int) d);
        System.out.println("Class2(double)");
    }

    Class2(int i) {                 // 2
        System.out.println("Class2(int)");
    }

    public static void main(String[] args) {
        new Class2(0.0);
    }
}

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes