class MainClass { public static void main(String[] args) { new Class2(); } MainClass() { System.out.print("Class1"); } } class Class2 extends MainClass { Class2() { System.out.print("Class2"); } }