CHAPTER 3
Mind Drill - Solved Questions
Tick (✔) the correct answer:
1. Which of the following operators are used to check the equality of two values?
a. +
b. -
c. ==
d. _
2. In an expression, there are two parts that are _______________ and Operator.
a. Calculation
b. Operand
c. Data type
d. None of these
3. Which type of operators work with only one operand?
a. Unary
b. Binary
c. Ternary
d. Logical
4. What will be the output of the following code?
int a = 3, b = 4;
System.out.print((a++) + ", " + (++b));
a. 4,5
b. 3,4
c. 3,5
d. 4,4
5. What will be the output of the following code?
int a = 3, b = 4;
a++;
++b;
System.out.print(a + ", " + b);
a. 4,5
b. 3,4
CHAPTER 3
c. 3,5
d. 4,4
Multiple Choice Questions
6. Which of the following is an equivalent expression of a = a + 4?
a. a+++
b. a += 4
c. a == 4
d. a + 4
7. What will be the result of the following code?
java
CopyEdit
int a = 10, b = 3, c = 0;
c = b % a;
a. 10
b. 0.3
c. 0
d. 3
8. What will be the output of the following code?
java
CopyEdit
int a = 1, b = 2, c = 3, d;
d = a++ / ++b * c;
System.out.print(d);
a. 0
b. 1
c. 2
d. 3
9. What will be the output of the following code?
java
CHAPTER 3
CopyEdit
double a = 1, b = 2, c = 3, d;
d = a++ / ++b * c;
System.out.print(d);
a. 0.0
b. 1.0
c. 2.0
d. 3.0
10. What will be the output of the following code?
java
CopyEdit
int a = 10, b = 30, c = 15;
System.out.println((a + b) < c ? (a + b) : (a - b));
a. 10
b. 40
c. -20
d. 20
11. Which of these is a valid Java expression for the following Math expression?
nginx
CopyEdit
u + 1 / 2ft²
a. u + 1.0 / 2.0f * t * t
b. u * t + 1 / 2 * f * t * t
c. (u * t) + (1.0 / 2.0 * f * t * t)
d. None of these
12. If a = 1 and b = 0, then what will return the following expression?
java
CopyEdit
(a > b) & (a < b)
CHAPTER 3
a. true
b. false
c. Both a and b
d. None of these
13. Which of the following operators is used to create the object of a class?
a. (dot)
b. new
c. ==
d. Unary
14. Which of the following operators will return true if both the expressions are true?
a. ||
b. &&
c. ++
d. --
15. Which of the following is not a form of operator in Java?
a. Binary
b. Unary
c. Ternary
d. None of these
Answers (Given in the Image)
Question Answer
1 c
2 b
3 a
4 c
5 a
6 b
7 d
8 a
9 b
CHAPTER 3
Question Answer
10 c
11 c
12 c
13 b
14 a
15 d