Constructor

  • Constructor is a special method that is called whenever an instance of the class is called.
  • It is without any return type.
  • It has same name as its class
  • The access modifier must be public as the constructors are called from out side the class.
  • A key benefit of using a constructor is that it guarantees that the object will go through proper initialization before being used. When a user instantiates an object, that object's constructor is called and must return before the user can perform any other work with that object. This guarantee helps ensure the integrity of the object and helps make applications written with object-oriented languages much more reliable.
  • If no constructor is implemented then the default constructor is supplied. The default constructor initializes the data members with default values. If the constructors are implemented then no default constructor will be supplied.

0 comments :

Post a Comment

> Related Posts with Thumbnails
 

Copyright © 2012. GS dot net - All Rights Reserved - Design by BTDesigner - Proudly powered by Blogger