Oracle
1Z0-851 · Question #83
Given: 1. interface DeclareStuff { 2. public static final int EASY = 3; 3. 4. void doStuff(int t); 5. } 6. 7. public class TestDeclare implements DeclareStuff { 8. public static void main(String[]…
The correct answer is D. Compilation fails. Cannot reduce the visibility of the inherited method from DeclareStuff
Analyzing and Troubleshooting System Problems
Question
Given: 1. interface DeclareStuff { 2. public static final int EASY = 3; 3. 4. void doStuff(int t); 5. } 6. 7. public class TestDeclare implements DeclareStuff { 8. public static void main(String[] args) { 9. int x = 5; 10. new TestDeclare().doStuff(++x); 11. } 12. 13. void doStuff(int s) { 14. s += EASY + ++s; 15. System.out.println("s " + s); 16. } 17.} What is the result?
Options
- As 14
- Bs 16
- Cs 10
- DCompilation fails.
- EAn exception is thrown at runtime.
How the community answered
(55 responses)- A5% (3)
- B13% (7)
- C2% (1)
- D76% (42)
- E4% (2)
Explanation
Cannot reduce the visibility of the inherited method from DeclareStuff
Topics
#Java interface#static final constant#method implementation#compilation error
Community Discussion
No community discussion yet for this question.