When applying strict “Private access” level to a component. Which services should the designer provide in its class to allow the object to communicate with the outside world? What should be the access level of these services?

Respuesta :

Answer:

public accessor methods

Explanation:

When applying strict “Private access” level to a component the designer should provide public accessor methods in its class to allow the object to communicate with the outside world. The access level of these services must be public so that they can be accessed by other classes and objects of the outside world.

Below is an example of such a class design in java :-

class MyClass {

private int num; //private class component

 

public int getNum(){ //public accessor method to allow the object to        communicate with the outside world

 return num;

}

}