Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

What happens if you create one argument constructor and do not create constructor without argument?

If class does not define any constructors, Java automatically creates default constructor with no arguments.  However, if constructor with arguments is specified, Java does not create default one.
 
Nothing happens if we do not specify the default constructor. However,

  1. Objects of that class can not be created using default constructor. It will give compilation error.
  2. Subclass of that class can not call super(). It will give compilation error.
Your rating: None Average: 5 (1 vote)
Share this

Post new comment

5 + 5 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.