Difference between Constructor and Method



Difference between Constructor and Method


Distinguish, differentiate, compare and explain what is the difference between Constructor and Method. Comparison and Differences.

What is the difference between Constructor and Method ?

1. Constructor is used to initialize the state of an object. Method is used to expose behavior of an object.

2. Constructor must not have return Method must have return type.

3. Constructor is invoked implicitly. Method is invoked explicitly.

4. The java compiler provides a default constructor if you dont have any constructor. Method is not provided by compiler in any case.

5. Constructor name must be same as the class name. Method name may or may not be same as class name.




Tags:

Difference between Method vs Constructor

Constructor vs Method

Differences between Method vs Constructor

Image Credits: Freepik

Spreading Knowledge Across the World

USA - United States of America  Canada  United Kingdom  Australia  New Zealand  South America  Brazil  Portugal  Netherland  South Africa  Ethiopia  Zambia  Singapore  Malaysia  India  China  UAE - Saudi Arabia  Qatar  Oman  Kuwait  Bahrain  Dubai  Israil  England  Scotland  Norway  Ireland  Denmark  France  Spain  Poland  and  many more....