Public: As the name describes, there are no limitation and restrictions in accessing an attribute or function attributed to an object. If Emmanuel who's an object(student that shares the general attributes of name, age, etc) in a class of 50 student wants to access his full name(that are attributes he possess) to fill a form, all he needs to do is to open the class register, take the names and use them in his form because they're made public. The names of everyone in that class is left open and students have ready access to their names.
The private property:
After every exams, 30 percent and 70 percent become attributes of the students. An external person is brought into the class to calculate the 100 percent by adding the 30 and 70 together. If a student wants to access his 100 percent score, he cannot access them directly since the 30 and 70 percent score have been given to the external person who has been added to the class to calculate. Until he releases the score to the student, no student will get access to the 100 score because the external person is the only who currently has access to the unreleased 30 and 70 percent scores of the students making the 30 percent and 70 score private attributes.
Protected:
When the private 100 percent score which is 30 and 70 score becomes protected, The external person calculating the 100 percent score protects it to himself and then can transfer the calculations to other classes that has also adopted the 30 percent and 70 percent score(basically inheritance)which he can go and calculate the hundred percent score in other similar classes.
Basically these access modifications will be implemented in a language soon.
Top comments (0)