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

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

Prepare for your Java exam with our ultimate quiz based on 'Thinking in Java'. Engage with expertly crafted questions that enhance your learning process. Perfect for Java enthusiasts looking to solidify their knowledge!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

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.