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

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

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

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.