In this example, the Person class encapsulates the name and age fields by making them private.
Public methods (GetName, SetName, GetAge, SetAge) are provided to access and modify these fields while enforcing validation rules.
This encapsulation ensures that the internal state of the Person object is controlled and manipulated only through well-defined methods.