How are this() and super() used with constructors

This() is used to invoke a constructor of the same class. super() is used to invoke asuperclass constructor.

Showing Answers 1 - 1 of 1 Answers

If we want to execute the constructor before executing the functionality of a method then we use this() constructor.This()refers the current constructor.

When we want to invoke the constructor of the super class first then we use super() constructor.It is used to invoke the super classs constructor from the subclasss constructor

  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