Skip to content
Quiz · Inheritance and polymorphism · lesson 2 of 10

Quiz — the order of constructors

What does the program print?

JAVA
public class Main {
    public static void main(String[] args) {
        new B();
    }
}
class A {
    A() { System.out.print("A"); }
}
class B extends A {
    B() { System.out.print("B"); }
}