Oracle
1Z0-803 · Question #8
Given a java source file: What changes will make this code compile?
The correct answer is C. changing the private modifier on the declarationof the one() method to protected. Using the private protected, instead of the private modifier, for the declaration of the one() method, would enable the two() method to access the one() method.
Working with Methods and Encapsulation
Question
Given a java source file:
What changes will make this code compile?
Exhibit
Options
- Aadding the public modifier to the declaration ofclass x
- Badding the protected modifier to the x()constructor
- Cchanging the private modifier on the declarationof the one() method to protected
- Dremoving the Y () constructor
- Eremoving the private modifier from the two () method
How the community answered
(23 responses)- A4% (1)
- C78% (18)
- D13% (3)
- E4% (1)
Explanation
Using the private protected, instead of the private modifier, for the declaration of the one() method, would enable the two() method to access the one() method.
Topics
#access modifiers#method declaration#constructor declaration#encapsulation
Community Discussion
No community discussion yet for this question.
