Static Variables and Methods

AP Computer Science A· difficulty 4/5

<code>class Counter { static int count = 0; }</code><code>Counter.count</code> is

  • A

    Cannot exist

  • B

    Always 0

  • C

    Each instance has own copy

  • D

    Shared by all instances

    check_circle

Explanation

Static = class-level (single shared variable).

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

Related questions