Constructors

AP Computer Science A· difficulty 3/5

What happens when the JVM evaluates <code>new Dog("Rex")</code>?

  • A

    Allocates memory and runs the constructor body

    check_circle
  • B

    Just allocates memory

  • C

    Returns null

  • D

    Just runs the constructor without allocation

Explanation

<code>new</code> allocates and initializes via constructor.

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

Related questions