Multiple choice technology architecture

How do you change the value that is encapsulated by a wrapper class after you have instantiated it?

  1. Use the setXXX() method defined for the wrapper class.

  2. Use the parseXXX() method defined for the wrapper class.

  3. Use the equals() method defined for the wrapper class.

  4. The value encapsulated by a wrapper class is immutable.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Wrapper classes in Java (Integer, Double, etc.) are immutable - once created, their value cannot be changed. Methods like setXXX() don't exist on wrapper classes. To 'change' a value, you must create a new wrapper object with the new value. This is a fundamental design choice in Java's type system.