Mastering Java: The Ultimate 2025 All-In-One Quiz to Excel in 'Thinking in Java'

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

Question: 1 / 515

What does the unary minus operator do?

Negates a boolean

Inverts the sign of the data

The unary minus operator, represented by the "-" symbol, changes the sign of the data it is applied to. It does this by multiplying the value by -1. This operation is commonly used in algebra to simplify equations and in programming to manipulate numerical values. The other options, such as A Negates a boolean and C: Increments the value, do not accurately describe the purpose of the unary minus operator. Option A refers to the logical "not" operation, which is not related to this question. Option C refers to the increment operator, which increases the value by 1, not changing its sign. Option D states that the operator does nothing, which is incorrect as it does have a defined purpose.

Increments the value

Nothing

Next

Report this question