What is a rules for defining a constructor

Total Post:38

Points:190

Java 
 927  View(s)
Ratings:
Rate this:
  1. What is a rules for defining a constructor

    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

Answer