Multiple choice technology platforms and products

What is this() in class?

  1. this() can be used to invoke a constructor of the same class

  2. this() will create the object of the same class

  3. There is no function called this(). It is a key word.

  4. this() will invoke the constructor of subclass

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In Java, this() is a special syntax used inside a constructor to invoke another overloaded constructor within the same class (constructor chaining). It must be the first statement in the constructor. It does not instantiate new objects directly or call subclass constructors.