📞 0339-0387701 (WhatsApp) Contact

« Back to Software Engineering (NCCIA)

A getter that returns a copy of an internal list, rather than the list itself, supports encapsulation by:

A. Hiding the class name
B. Preventing callers from modifying internal state directly ✅
C. Deleting the list
D. Making the program slower only

Correct Answer: B. Preventing callers from modifying internal state directly

Explanation

  • Returning a copy protects the internal collection
  • Returning the live list would let callers change state unchecked.