220k views
3 votes
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?

User Marites
by
4.5k points

1 Answer

3 votes

Answer:

public accessor methods

Step-by-step 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;

}

}

User The Kraken
by
5.2k points