Creating References Using Inheritance Hierarchies

AP Computer Science A· difficulty 4/5

<code>if (a instanceof Dog) ...</code> is true when

  • A

    a's runtime type is Dog or a Dog subclass

    check_circle
  • B

    a is the literal Dog class

  • C

    a is null

  • D

    Always

Explanation

<code>instanceof</code> checks whether the object is of the named type or a subtype; false for null.

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

Related questions