What is the result of the following code?
1: public interface Printable { 2: public abstract void print(); 3: } /*from w w w .j a va2 s . c om*/ 4: public interface Log extends Printable {} 5: public abstract class ConsoleLog implements Log { 6: public abstract void log(); 7: } 8: public class DosConsoleLog extends ConsoleLog { 9: public void log() { System.out.println("Dos ConsoleLog is logging"); } 10: }
E.
The code does not compile because DosConsoleLog
inherits the abstract method print()
but does not implement it, therefore the correct answer is E.
B, C, and D are incorrect as they compile for various reasons.
Line 2 compiles, as non-static and non-default interface methods are assumed to have the abstract modifier.
Line 4 compiles without issue as an interface can extend another interface.
Line 5 compiles without issue as an abstract class can implement an interface without implementing any of the abstract methods.
F is incorrect, as Line 8 does not compile.