1. Given: 1. class Zing { 2. protected Hmpf h; 3. } 4. class Woop extends Zing { } 5. class Hmpf { } Which is true? (Choose all that apply.)
  1. Woop is-a Hmpf and has-a zing.

  2. zing is-a Woop and has-a Hmpf.

  3. Hmpf has-a Woop and Woop is-a Zing.

  4. Woop has-a Hmpf and Woop is-a zing.

  5. Zing has-a Hmpf and Zing is-a Woop.


Correct Option: D

AI Explanation

To answer this question, let's go through each option:

Option A) Woop is-a Hmpf and has-a zing. This option is incorrect because Woop is not a Hmpf and there is no mention of a zing in the given code.

Option B) zing is-a Woop and has-a Hmpf. This option is incorrect because zing is not a Woop and there is no mention of a Hmpf in the given code.

Option C) Hmpf has-a Woop and Woop is-a Zing. This option is incorrect because Hmpf does not have a Woop and Woop is not a Zing.

Option D) Woop has-a Hmpf and Woop is-a zing. This option is correct because Woop does have a Hmpf (as inherited from the parent class Zing) and Woop is not a zing (case-sensitive error).

Option E) Zing has-a Hmpf and Zing is-a Woop. This option is incorrect because Zing does not have a Hmpf and Zing is not a Woop.

The correct answer is D. Woop has-a Hmpf and Woop is-a zing.

Find more quizzes: