Monday, June 28, 2010

What are Constructors

! Constructors are similar to methods.
! They always take the name of the class but no return type.
! Constructors cannot be called/ inherited can only be invoked by 'new' operator.
! They allocate memory to all of class/member variables to keep default values in it.
! Class has one single constructor & it is private and can never be instantiated.
! Static Constructors -- Used for initializing only static members of a class..These are invoked very first time class is loaded in memory. No args. No Access Modifiers.
! Non-Static Constructors -- Used for initializing static & non-static methods. Invoked every time a new object is created.

0 comments:

Post a Comment