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 static methods?

  1. They can't use this

  2. They can access instance methods directly

  3. They are only used in static classes

  4. They cannot be private

The correct answer is: They can't use this

Static methods do not require an instance of the class to be called, hence they cannot use `this` keyword to reference the current instance. This means that they cannot access any instance methods or variables directly. Option C is incorrect because static methods can also be used in non-static classes. Option D is incorrect because static methods can be private as well.