What is constructor chaining and how to do this in Java?

What is constructor chaining and how to do this in Java?

Contructor can be overloaded,i.e. a single class can hava more than one contructor. A construct may call to another constructor. The first statement in the constructor must be a call to either this() or  super() but not both. The super() will call the matching superclass constructor according to the number of arguments passed in the super(). A this() will call the overloaded constuctor in the same class according to the parameter list. The called constructor may also make a call to the other constructor using this(). This type of contructor calling in the same class is called constructor chaining.


By:Jalees
Date:2014-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher