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.


What should generally be preferred over inheritance during the first design cut?

  1. Encapsulation

  2. Composition

  3. Interfaces

  4. Static methods

The correct answer is: Composition

During the initial design phase, composition is generally preferred over inheritance. This is because composition allows for greater flexibility and easier maintenance in the long run. Encapsulation, interfaces, and static methods may also be useful design tools, but they are not exclusive alternatives to inheritance and may not be as effective in terms of code organization and overall design. Therefore, composition is the most suitable option for the first design cut.