What difference between constructor and method?

What difference between constructor and 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.


By:Vivek Raj
Date:2028-05-15 00:00:00

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.


By:Vivek Raj
Date:2028-05-15 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher