Creating References Using Inheritance Hierarchies

AP Computer Science A· difficulty 4/5

Method declared <code>Animal getAnimal()</code> can return

  • A

    Animal only

  • B

    Compile error if returning Dog

  • C

    Animal or any subclass instance

    check_circle
  • D

    null only

Explanation

Subclass instance "is-an" Animal; can be returned.

Want 10 more like this — adaptive to your weak spots?

Related questions