Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

Practice this question and more.


Can constructor in Java be overridden?

  1. Yes

  2. No

  3. Only if it is a default constructor

  4. Only in a subclass

The correct answer is: No

In Java, constructors cannot be overridden. This is because unlike methods, constructors cannot be inherited by subclasses. This means that a subclass cannot override the constructor of its superclass. However, a subclass can specify which constructor of the superclass should be invoked when creating an instance of the subclass. Option A is incorrect because constructors cannot be overridden, but can be invoked through the use of the super keyword. Option C is incorrect because the type of a constructor (default or non-default) does not affect its ability to be overridden. Option D is incorrect because as stated, constructors cannot be overridden in Java.