Tag: constructors override

Constructors and Constructor overloading

March 31, 2011 · 5 min read
A **constructor** looks more like a method but without return type. Moreover, the name of the constructor and the class name should be the same. The advantage of constructors over methods is that they are **called implicitly** whenever an object is created. In case of methods, they must be called explicitly. To create an object, the constructor must be called. Constructor gives properties to an object at the time of creation itself (else, it takes some method calls with extra code to do the same job). Programmer uses constructor for initializing variables, instantiating objects and setting colors. Constructor is equivalent to [init()](http://way2java.com/applets/life-cycle-of-applet/) method of an [applet](http://way2java.com/applets/applets-vs-applications/).