Object Superclass

AP Computer Science A· difficulty 2/5

public class Foo {
}
// ...
Foo f = new Foo();
Object o = f;

Which statement is true?

  • A

    Object is a primitive type

  • B

    Foo cannot be assigned to an Object reference

  • C

    Every class implicitly extends Object, so Foo is-a Object

    check_circle
  • D

    Foo cannot inherit from Object because Foo has no superclass

Explanation

All Java classes (other than Object itself) implicitly extend Object, so a Foo reference is assignable to an Object reference.

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

Related questions