Constructor Call

How can we call a constructor through another constructor in the same class?

Questions by sailendra.n.jena   answers by sailendra.n.jena

Showing Answers 1 - 3 of 3 Answers

There is no way to invoke a constructor explicitly.

Respective constructor is invoked only at the creation of object.
For Ex:
Hello h=new Hello(); // This will invoke default constructor if exists
Hello h=new Hello(10);    // This will invoke one arg constructor if exists
Constructor are automatically invoked by JVM.

However if u inherited the class then we can invoke super class constructor from sub class using super keywork

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions