This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
multiple constructor - answer
Posted by Y.M.Sudarsan on August 08, 2000 at 10:13 AM
> In a Multiple constructor class, a constructor can call another constructor. How to call it?
> Assume there are three constructors in the class you consider.
> Please write a class that contains:
> a) three constructor (and some other codes)
> b) the third constructor calls the second constructor and the second one calls the first
> write a sub-class (extends the first class) that contains one constructor invoking
> one of constructor in the super-class.
The solution for you problem is as seen in the following code.
You invoke the constructor by ceating a new object.
//code by Y.M.Sudarsan firstname.lastname@example.org
public static void main(String args)
second s1 = new second();
System.out.println("cons with i "+i);
System.out.println("cons with s "+s);
class second extends f