0% found this document useful (0 votes)
6 views4 pages

Java Operators MCQ Worksheet Part 2

The document contains a multiple-choice question worksheet focused on operators in Java, including various expressions and their expected outputs. Each question tests knowledge of arithmetic, relational, and logical operators, along with operator precedence. Correct answers are indicated for some questions, providing a resource for learning Java operators.

Uploaded by

Parul Mittal
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

Java Operators MCQ Worksheet Part 2

The document contains a multiple-choice question worksheet focused on operators in Java, including various expressions and their expected outputs. Each question tests knowledge of arithmetic, relational, and logical operators, along with operator precedence. Correct answers are indicated for some questions, providing a resource for learning Java operators.

Uploaded by

Parul Mittal
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MCQ worksheet on Operators in Java part 2

1) What will be the result of the following expression?

int a = 15;

int b = 4;

int result = a % b;

[Link](result);

a) 1

b) 2 Option c is correct
c) 3

d) 4

2) What will be the output of the following code?

double a = 10.5;

int b = 3;

double result = a / b;

[Link](result);

a) 3

b) 3.5

c) 10.5

d) 3.0

3) What will be the result of the following code snippet?

boolean a = true;

boolean b = false;

boolean c = true;

[Link](a && b || c);

a) true

b) false Option a is correct

c) 0

d) 1
MCQ worksheet on Operators in Java part 2

4) Evaluate the following expression:

boolean result = (5 > 3) && (3 < 1) || (2 == 2);

[Link](result);

a) true
Option a
b) false

c) 0

d) 1

5. What will be the output of the following code?

int a = 25;

int b = 25;

[Link](a >= b);


Option a
a) true

b) false

c) 25

d) 50

6) Which of the following is not a relational operator?

a) ==
Option d
b) <

c) <=

d) &&

7. What will be the output of the following code?

int a = 5;

int b = 10;

String result = (a < b) ? "a is less than b" : "a is not less than b";
Option a
[Link](result);

a) a is less than b

b) a is not less than b


MCQ worksheet on Operators in Java part 2

c) Error

d) None of the above

8) What is the output of the following code?

int a = 10;

int b = 20;

int c = (a < b) ? (a + b) : (a - b);

[Link](c);
Option c
a) 10

b) 20

c) 30

d) -10

9. What is the output of the following code?

int a = 15;

a = -a;

[Link](a); Option b
a) 15

b) -15

c) 0

d) Error

10) What will be the result of the following code?

int a = 10;

int b = ++a;

[Link](a + " " + b); Option b

a) 10 10

b) 10 11

c) 11 10

d) 11 11
MCQ worksheet on Operators in Java part 2

11. What will be the output of the following expression?

int a = 5;

int b = 10;

int c = 15;

int result = a + b * c / a - b;
None, answer is 25
[Link](result); Solution:
Result = 5+10*15/5-10
a) 0 =) 5 + 150/5-10
=) 5+30-10
b) 10
=)5+20
c) 15 =) 25

d) 20

12) Evaluate the following expression:

int result = 10 + 5 * 2 - 3 / 1;

[Link](result); Option c
a) 19

b) 23

c) 17

d) 20

13) What will be the result of the following expression considering operator precedence?

int result = 10 - 5 + 2 * 4 / 2;

[Link](result);

a) 6

b) 11 Option d
c) 7

d) 9

You might also like