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 operator is used in Java to show equality between two variables?

  1. =

  2. ==

  3. ===

  4. !=

The correct answer is: ==

In Java, the == operator is used to check for equality between two variables. This means that it will return true if the two variables store the same value, and false if they do not. Option A, the = operator, is used to assign a value to a variable. Option C, the === operator, is not a valid operator in Java and should not be used. Option D, the != operator, checks for inequality between two variables, meaning it will return true if the variables store different values and false if they store the same value. Therefore, it is also not the correct operator to use in this scenario.