Java.lang Class - Programming

Q1:

What will be the output of the program?
class A 
{ 
    public A(int x){} 
} 
class B extends A { } 
public class test 
{ 
    public static void main (String args []) 
    {
        A a = new B(); 
        System.out.println('complete'); 
    } 
}

A It compiles and runs printing nothing

B Compiles but fails at runtime

C Compile Error

D Prints "complete"

ANS:A - It compiles and runs printing nothing

No constructor has been defined for class B therefore it will make a call to the default constructor but since class B extends class A it will also call the Super() default constructor. Since a constructor has been defined in class A java will no longer supply a default constructor for class A therefore when class B calls class A's default constructor it will result in a compile error.