Multiple choice technology programming languages

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

  1. This() is used to invoke a constructor of the same class. super() cannot invoke a superclass constructor.

  2. Super() is used to invoke a constructor of the same class. This() is used to invoke a superclass constructor.

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

  4. None of the above.

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

In Java, this() is used to call another constructor in the same class (constructor chaining), while super() is used to call a constructor in the superclass. Both must be the first statement in a constructor if used.