Accessor Methods

AP Computer Science A· difficulty 3/5

A typical "getter" for <code>private int age;</code>

  • A

    public int age() { age++; }

  • B

    public void getAge() { return age; }

  • C

    public static int getAge();

  • D

    public int getAge() { return age; }

    check_circle

Explanation

Returns the field; non-static; no parameters.

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

Related questions