WHAT IS THE DIFFERENCE BETWEEN A CONSTRUCTOR AND A METHOD?

Chris Anderson

Total Post:197

Points:985
Posted by  Chris Anderson
Java 
 2140  View(s)
Ratings:
Rate this:
  1. Chris Anderson

    Post:197

    Points:985
    What is the difference between a constructor and a method?

    A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator.
    A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.

Answer

NEWSLETTER

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