Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What is the difference constructor and method?

user-image
Question added by Ramakrishna Ilavarapu
Date Posted: 2014/04/15
Maria Thomas
by Maria Thomas , Tech Lead , J P Morgan Chase

Constructor is the point of initialisation of any object. If an explicit constructor is not given, the class has a default no arguments constructor that is internal to it which would be called when the object is created using the new operator. Constructor does not have a return type.

In contrast a method is created by the user to do some actions on the object. It is explicitly invoked on the object. It has a return type.

shabbir hussain
by shabbir hussain , Billing Analyst Consultant , Ebone Network (Private) Limited

The important difference between constructors and methods is that constructors create and initialize objects that don't exist yet, while methods perform operations on objects that already exist.

More Questions Like This