Page 76 - CA_Blue( J )_Class10
P. 76
6. Which of the following is an example of a unary operator in Java?
a. += b. *
c. ++ d. ==
7. Which operator would you use to check if two conditions are both true in Java?
a. || b. &&
c. == d. &
8. Which of these operators has the highest precedence in Java?
a. + (addition) b. && (logical AND)
c. = (assignment) d. * (multiplication)
9. What type of operator is && in Java?
a. Arithmetic operator b. Bitwise operator
c. Logical operator d. Relational operator
10. What will be the result of the following expression in Java? !(false && true)
a. false b. true
c. null d. 0
B. Fill in the blanks.
1. Arrange these operators (<, ++, +, %) in order of higher precedence to lower precedence ………………….
2
2. The equivalent Java expression for a +b +2ab is ………………….
2
3. The output of the expression a += a++ * ++a % a is ………………… if a is 5.
4. The expression (true) || (true) will return ……………….
5. The expression 10 % 3 will return ………………….
C. Answer the following questions:
1. What is the output of the following expressions if executed sequentially? Where a = 10, b = 2 and c = 8.
• c += a / ++b * c
• a = c + b++ * (a + b + c)
2. What will be the output of the following ternary expression if int a = 5, b = 3 and double d?
d = (a >= b) ? (a + b) : (a * b);
3. What is the difference between the ternary operator and the unary operator? Give one example of each.
4. Write the Java expressions of the following mathematical expressions:
(B+C)
• A = × h
2
2
• V = πr × h
5. Name the operators listed below:
a. >= b. !=
c. -- d. +=
e. % f. ||
6. Give the output of the following expressions:
• a = ++a + a-- / ++a + --a; when a = 2.
• i *= j++ % j-- / k *10; when i=2,j=4,k=3
D. Assertion and Reasoning based questions.
The following questions consist of two statements – Assertion (A) and Reason (R). Answer these questions by selecting the appro-
priate option given below:
a. Both A and R are true, and R is the correct explanation of A.
b. Both A and R are true, but R is not the correct explanation of A.
c. A is true, but R is false.
d. A is false, but R is true.
7474 Touchpad Computer Applications-X

