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

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

Dive into the depths of Java with our quiz based on "Thinking in Java, Fourth Edition" by Bruce Eckel. Test your knowledge, solidify concepts, and prepare for certification with challenging questions and insightful feedback.

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


How can one constructor call another constructor in the same class?

  1. Using super()

  2. Using this()

  3. Using init()

  4. Directly calling the constructor by name

The correct answer is: Using this()

One constructor can call another constructor in the same class by using the keyword "this" followed by parenthesis and any necessary arguments. This is known as constructor chaining and allows the code to be more organized and easier to maintain. In contrast, super() is used to call a constructor from a superclass, init() is not a valid keyword for calling constructors, and directly calling the constructor by name is not a recommended practice and can lead to code duplication and confusion.