WHAT IS A RULES FOR DEFINING A CONSTRUCTOR

Samuel Fernandes

Total Post:38

Points:190
Posted by  Samuel Fernandes
Java 
 332  View(s)
Ratings:
Rate this:
  1. Samuel Fernandes

    Post:38

    Points:190
    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

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!