class A{
A(int a)
{
System.out.println("object created");
}
}
class constructortest {
public static void main(String[] args) {
A a1 = new A();
}
}
A)
Output:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
A cannot be resolved to a type
A cannot be resolved to a type
at constructortest.main(constructortest.java:8)
->in the above program causes “compilation error”.
->reason is, in the object creation syntax zero argument constructor is used, but zero argument constructor not available in the class.
Comments
Post a Comment