Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

Practice this question and more.


What must classes do to conform to an interface?

  1. Declare all interface fields

  2. Implement all abstract methods

  3. Extend another concrete class

  4. Provide default implementations

The correct answer is: Implement all abstract methods

Classes that implement an interface must provide implementations for all of the abstract methods declared in the interface. Option A is incorrect because interfaces do not have fields, they only have method signatures. Option C is incorrect because interfaces cannot be extended, they are implemented. Option D is incorrect because interfaces do not have default implementations, they only provide method signatures. Therefore, the correct answer is B, since implementing all the abstract methods in an interface is a key requirement for classes to conform to an interface.