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 does the unary minus operator do in Java?

  1. Negates the operator

  2. Removes minus sign if present

  3. Doubles the value

  4. Converts to positive if negative

The correct answer is: Negates the operator

The unary minus operator in Java is used to negate a value, i.e., changing a positive value to a negative value or vice versa. This means that it performs the opposite operation of the given value. The other options, such as removing a minus sign if present or doubling the value, are not the expected behavior of the unary minus operator. Additionally, while the operator may convert a negative value to a positive value, its main purpose is to simply negate a value. Therefore, the best answer choice is A.