Home > DeveloperSection > Interviews > What is a rules for defining a constructor

Posted on    November-07-2016 1:18 AM

 Java Java 
Ratings:
 1 Answer(s)
  43  View(s)
Rate this:

Samuel Fernandes
Samuel Fernandes

Total Post:28

Points:140
Posted on    November-07-2016 1:18 AM

The rules for constructor creation can be summarized as follows:

•A constructor must have the same name as the class name.
•A constructor does not return anything, not even a void type.
•A constructor may take zero or more arguments.
•By default, the compiler provides a no-argument constructor.
•If you provide any constructor—either a no-argument constructor or a constructor with arguments—the compiler does not provide a default constructor.

Thanks

Don't want to miss updates? Please click the below button!

Follow MindStick