Tuesday, 11 August 2015

Difference between Methods and Constructors in Java

Methods Vs Constructors in Java

What is the difference between Methods and Constructors in Java?

               It is obvious that Constructor and Method in Java make confusion for the beginners. Here are few points which illustrate the difference between a constructor and method in Java.





It is not necessary to use the same name of the class to create a Method.

The name of the Constructor should be same as the class name it resides.


Method is an ordinary member function which is used to expose  the behavior of an object

Constructor is a member function of a class used to initialize the state of an object


Methods must have return type unless it is specified as void.

Constructor does not have a return type.


Compiler does not create a method in any case if one is not available.

Java compiler creates default constructor if the program doesn’t have one.


Methods invoked explicitly. 
Invoked using the dot operator.

Constructor invoked implicitly. i. e. Invoked using the keyword ‘new’.

               Hoping that the above table gives an idea about how Constructors are different from methods in Java.

Constructor Method Difference


  1. Great post. It definitely helped me. So thanks

    Grid false Ceiling in chennai

  2. Thank you for sharing this wonderful information with us. It was really helpful.

    Web designing course in Chennai

  3. Well difference in both cases.