Scope and Access

AP Computer Science A· difficulty 3/5

Why hide instance variables behind getters/setters?

  • A

    Required by Java

  • B

    Slower

  • C

    Allows validation, future implementation changes, and protects invariants

    check_circle
  • D

    Saves memory

Explanation

Encapsulation supports maintenance and consistency.

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

Related questions