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

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

Dive into the depths of Java with our quiz based on "Thinking in Java, Fourth Edition" by Bruce Eckel. Test your knowledge, solidify concepts, and prepare for certification with challenging questions and insightful feedback.

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 keyword is used to declare a class variable (static field)?

  1. global

  2. class

  3. static

  4. public

The correct answer is: static

The keyword used to declare a class variable, or a variable that is associated with an entire class rather than a single instance of that class, is "static". This allows the variable to be accessed and modified by all instances of the class, as well as directly using the class name without creating an instance of the class first. The options A, B, and D are incorrect because they do not specifically indicate the variable's connection to a class and could be used for other purposes, such as declaring a variable with global scope or within a public access modifier. It is important to use the keyword "static" to clearly indicate the intended use and scope of the variable.