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 are the fields in an interface implicitly?

  1. Public and final

  2. Private

  3. Protected

  4. Static only

The correct answer is: Public and final

When you implement an interface, all methods are implicitly public if they are not declared as anything else. This means that they can be accessed by any other class in the program. Additionally, all variables defined in an interface are automatically public, final, and static, meaning that they cannot be changed and can be accessed globally. Option B and C are both incorrect because private and protected keywords are not allowed in an interface. Option D is incorrect because the variables in an interface are not implicitly static, they are explicitly static.