In Java, what does the - operator perform?

Prepare for the Computer Programming Test. Study with flashcards and multiple-choice questions, each with detailed hints and explanations. Gear up for success!

Multiple Choice

In Java, what does the - operator perform?

Explanation:
The minus sign between two numbers performs subtraction: it subtracts the right-hand value from the left-hand value. For example, 7 - 3 equals 4. This is the binary form of the operator. It can also be used as a unary operator in front of a single operand to negate it (for instance, -x becomes the negation of x). In Java, binary subtraction works with all numeric types (int, long, float, double, etc.) and yields a numeric result of the appropriate type. The other arithmetic operators use different symbols: + for addition, / for division, and % for modulo. So the symbol - corresponds to subtraction.

The minus sign between two numbers performs subtraction: it subtracts the right-hand value from the left-hand value. For example, 7 - 3 equals 4. This is the binary form of the operator. It can also be used as a unary operator in front of a single operand to negate it (for instance, -x becomes the negation of x). In Java, binary subtraction works with all numeric types (int, long, float, double, etc.) and yields a numeric result of the appropriate type. The other arithmetic operators use different symbols: + for addition, / for division, and % for modulo. So the symbol - corresponds to subtraction.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy