Question
What is the purpose of the usual access level modifiers trio private, protected, public? Select one: a. They modify the level of exposure of a
What is the purpose of the usual access level modifiers trio "private, protected, public"?
Select one:
a. They modify the level of exposure of a class attributes (variable) or methods to the "world" outside the said class. In a class C1 For C1 attributes:
- Private: encrypts the content of the attribute for all methods outside C1
- Protected: encrypts the content of the attribute for all methods outside C1 and its subclasses.
- Public: unencrypted value, almost like "no encapsulation".
For C1 methods:
- Private: callable only by other methods in C1, not inherited in subclasses, code is totally encrypted
- Protected: callable by other methods in C1, inherited in all its subclasses, callable by methods of C1 subclasses, code is encrypted outside the class hierarchy, readable within.
- Public: callable everywhere, code readable everywhere.
b. They modify the level of exposure of a class attributes (variable) or methods to the "world" outside the said class. In a class C1 For C1 attributes:
- Private: provide a "read protection" against any methods not member of C1.
- Protected: provide a "read protection" against any methods not member of C1 or its subclasses.
- Public: read accessible from everywhere, almost like "no encapsulation".
For C1 methods:
- Private: callable only by other methods in C1, not inherited in subclasses, code is totally obfuscated
- Protected: callable by other methods in C1, inherited in all its subclasses, callable by methods of C1 subclasses, code is obfuscated outside the class hierarchy, readable within.
- Public: callable everywhere, code readable everywhere.
c. They modify the level of exposure of a class attributes (variable) or methods to the "world" outside the said class. In a class C1 For C1 attributes:
- Private: accessible only to methods of C1.
- Protected: accessible to methods of C1 and all methods of its subclasses.
- Public: accessible everywhere, almost like "no encapsulation".
For C1 methods:
- Private: callable only by other methods in C1, not inherited in subclasses.
- Protected: callable by other methods in C1, inherited in all its subclasses, callable by methods of C1 subclasses.
- Public: callable everywhere.
4
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started