Java OCA OCP Practice Question 1020

Question

Given the following code, which of the results that follow would you expect?

1. package mail; 
2. 
3. interface Box { 
4.    protected void open(); 
5.    void close(); 
6.    public void empty(); 
7. } 
  • A. The code will not compile because of line 4.
  • B. The code will not compile because of line 5.
  • C. The code will not compile because of line 6.
  • D. The code will compile.


A.

Note

All methods in an interface must be public.

The default access modifier automatically assumes the method or constant to be public.




PreviousNext

Related