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

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

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

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.