OCA Java SE 8 Class Design - OCA Mock Question Class Design 6








Question

Choose the correct statement about the following code:

     1: public interface Printable { 
     2:   void myMethod(); 
     3: } 
     4: interface Formattable { 
     5:   public abstract Object format(); 
     6: } 
     7: abstract class Paper implements Printable, Formattable { 
     8: } 
  1. It compiles without issue.
  2. The code will not compile because of line 2.
  3. The code will not compile because of line 4.
  4. The code will not compile because of line 5.
  5. The code will not compile because of lines 2 and 5.
  6. The code will not compile because the class Paper doesn't implement the interface methods.




Answer



A.

Note

Methods from lines 2 and 5 will be converted to public abstract by the compiler.

Line 4 is fine, because an interface can have public or default access.

Class Paper doesn't need to implement the interface methods since it is marked as abstract. Therefore, the code will compile without issue.