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.


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.