What is the primary purpose of encapsulation in OOP?
A) To increase code complexity.
B) To allow for method overloading.
C) To hide the internal state and require all interaction to occur through an object's methods.
D) To facilitate multiple inheritance.
Answer: C) To hide the internal state and require all interaction to occur through an object's methods.
Explanation: Encapsulation is primarily aimed at protecting the internal state of an object. By exposing only necessary methods (the public interface) and keeping the rest private, it prevents external code from manipulating the object's state directly. This leads to increased security and maintainability of the code, as the internal representation of the object can change without affecting external code that uses it.