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 is true about methods in a Java interface?

  1. They can have method bodies if marked static

  2. They are automatically public

  3. They must be abstract

  4. They can be private

The correct answer is: They are automatically public

Interface methods are automatically public, meaning they can be used and accessed by any other class. Option A is incorrect because static methods do not require an object to be called and interfaces cannot have objects. Option C is incorrect because all interface methods are abstract, meaning they do not have a method body. Option D is incorrect because all interface methods are public and therefore cannot be private.