Java OCA OCP Practice Question 503

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, which of the following fields would be appropriate for inclusion in the Cat class as members?

Choose all that apply.

A.  Pet thePet; 
B.  Date registered; 
C.  Date vaccinationDue; 
D.  Cat theCat; 
E.  boolean neutered; 
F.  String markings; 


E, F.

Note

The Cat class is a subclass of the Pet class, and as such should extend Pet, rather than contain an instance of Pet.

B and C should be members of the Pet class and as such are inherited into the Cat class; therefore, they should not be declared in the Cat class.

D would declare a reference to an instance of the Cat class, which is not generally appropriate inside the Cat class.

The neutered flag and markings descriptions, E and F, are the items called for by the specification; these are correct items.




PreviousNext

Related