Variables and Data Types

AP Computer Science A· difficulty 4/5

A LOCAL <code>int</code> variable used without being initialized causes

  • A

    Runtime exception

  • B

    Defaults to undefined

  • C

    Defaults to 0

  • D

    Compile error

    check_circle

Explanation

Locals (unlike instance fields) must be definitely assigned before use; otherwise compile error.

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

Related questions