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

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

Want to excel in Java? Test your knowledge with our ultimate quiz based on 'Thinking in Java'. Engage with multiple-choice questions and in-depth explanations. Boost your understanding and prepare for your exam with confidence.

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 type of operators are + and - when applied to a single operand in Java?

  1. Unary operators

  2. Binary operators

  3. Ternary operators

  4. Bitwise operators

The correct answer is: Unary operators

Unary operators are operators that perform an operation on a single operand. In Java, the plus (+) and minus (-) signs can be used as unary operators when applied to a single operand. This means that they operate on only one value. Binary operators, on the other hand, are operators that involve two operands, such as +, -, *, /, etc. Ternary operators, also known as conditional operators, involve three operands and are used for conditional expressions. Bitwise operators, such as &, |, or ^, perform operations on the binary representation of the operands. Therefore, these options are incorrect because they do not correctly describe the behavior of + and - when applied to a single operand in Java.