1
This is a question of the Secitec 2018 competition for the position of computer teacher. I appealed to this question because there are no qualifiers, but access modifiers such as: private, protected and public. The reserved word "package" is not an explicit access modifier according to Deitel & Deitel. What alternative in this case would be the correct one? Then the question follows.
Encapsulation is one of the basic principles used in object-oriented programming, which makes it possible to restrict access to variables and methods a class. To determine the access level of elements of a class are used qualifiers, two of them are characterized below.
(I) It is the most rigid level at which only the methods of the own class have access to variables and other methods.
(II) Is the level at which variables and methods can be accessed only by other classes belonging to to the same package.
The qualifiers (I) and (II) are called, respectively:
A) public and package
B) public and protected
C) private and package
D) private and protected
Would the D alternative not be correct? The protected modifier defines, for the element (variable or method), the package level access, correct?
– Rodrigo Costa
As the term "only" was used in affirmation II, I think protected is excluded, because a subclass in another package could not access since "only" classes of the same package would be allowed. Already with protected this would be possible.
– Piovezan
Correct. Thank you very much!
– Rodrigo Costa
If the answer was useful to you, you can accept it by clicking on the "v" in the upper left corner of it, below the polling arrows.
– Piovezan