Advertisements
Advertisements
Questions
Explain the following with one example.
Arithmetic operator
Give two examples of Arithmetic operators.
Answer in Brief
Solution
Arithmetic operators perform arithmetic operations within a program. Unary arithmetic operators apply to a single operand (prefix or postfix), while Binary arithmetic operators deal with two operands. Shorthand binary operations also employ Binary operators.
Example:
-
+, −, ++, −−, *, /, &, %
-
sum += b; // shorthand
-
int c = num % 2
shaalaa.com
Notes
Students should refer to the answer according to their question and preferred marks.
Is there an error in this question or solution?
Chapter 1.04: Operators in Java - EXERCISES [Page 44]