You can access private attributes using public methods that return or change the values of the private attributes.
The slightly higher runtime requirement (method calls in comparison with direct value assignment) is taken into account to satisfy the encapsulation concept.
The signature of a public method clearly establishes which values must or can be transferred, and which types are to be assigned to these values. The signature of a public method forces the external user to use the correct types. This method also ensures that all private attributes are dealt with consistently.
For example, in the figure, if the MAKE and MODEL attributes are public, it will be risky because the user may forget to supply the attributes or specify inconsistent attributes.
To solve this situation, you can use a public method, SET_TYPE, to ensure that proper values are specified for both the attributes. A strict syntax check governs method calls, ensuring the transfer of all required parameters. A method can perform a consistency check (to see if a certain vehicle makes produces the chosen model) and raise an exception if an error occurs.
To minimize runtime, individual attributes can be defined in the public visibility section. After you have defined the attributes give them the READ-ONLY addition.
Static Attributes and Instance Attributes
Different kinds of attributes are as follows:

Instance Attributes and Static Attributes in the Program Context
The figure shows how the GV_N_O_VEHICLES static attribute is related to other program elements in the memory. The static attribute exists only once in the loaded class, regardless of the number of instances of LCL_VEHICLE. Therefore, you can say that instances share static attributes.
Caution: An integer data object is defined to count instances. It is not possible to find out the number of created instances from the system.

Implementation of Methods
Some of the key characteristics of methods are as follows:

Method Signature
You can define all input parameters (IMPORTING and CHANGING parameters) as optional parameters in the declaration using the OPTIONAL or DEFAULT addition. You do not need to pass these parameters when you call the object. By using the OPTIONAL addition, the parameter initializes according to type, while the DEFAULT addition allows you to enter a start value.
Methods also support the SY-SUBRC return value, but only when you define the signature exceptions with the use of EXCEPTIONS. Use the RAISING addition in place of EXCEPTIONS to propagate class-based exceptions. The caller then handles these class-based exceptions without evaluating the SY-SUBRC return value.
Functional methods have one RETURNING parameter as well as importing parameters and exceptions.
Visibility of Methods