Java OCA OCP Practice Question 507

Question

You have been given a design document for implementation in Java.

It states:

  • A pet has an owner, a registration date, and a vaccination-due date.
  • A cat is a pet that has a flag indicating whether it has been neutered, and a textual description of its markings.

Given that the Pet class has already been defined and you expect the Cat class to be used freely throughout the application.

How would you make the opening declaration of the Cat class, up to but not including the first opening brace?

  • A. protected class Cat extends Owner
  • B. public class Cat extends Object
  • C. public class Cat extends Pet
  • D. private class Cat extends Pet


C.

Note

The class should be public, because it is to be used freely throughout the application.

The statement "A cat is a pet" tells you that the Cat class should subclass Pet.




PreviousNext

Related