ProgrammingModerateProduct-company placement · Java

What happens when this is compiled?

What happens when this is compiled?
interface I { void a(); void b(); }
abstract class P implements I { public void a() { } }
class C extends P { }
  1. A. It compiles; P already implements I
  2. B. Compile-time error in P: it must implement b()
  3. C. Compile-time error: C must implement b()
  4. D. It compiles; calling b() throws AbstractMethodError

Correct answer: C. Compile-time error: C must implement b()

An abstract class may leave interface methods unimplemented, but the first concrete subclass must implement every remaining abstract method, here b().

More OOP with C++ and Java questions

Exams that ask this topic