Wednesday, March 13, 2013

Constructor VS Method in Java

Constructor
 Method
A constructor is used to initialize the instance variables of a class.
A Method is used for any general purpose processing or calculations.
A constructors name and class name should be same.
A method’s name and class name can be same or different.
A constructor is called at the time of creating the object.
A method can be called after creating the object.
A Constructor  is called only once per object.
A method can be called several times on the object.
A constructor is called and executed automatically.
A method is executed only when we call it.


No comments:

Post a Comment