Sunday, July 21, 2024

Logical Operators in Java MCQ

 What is the result of the logical AND operator (&&) if both conditions are true?

a) True

b) False

c) 0

d) 1


Which symbol represents the logical OR operator in Java?

a) &&

b) ||

c) !

d) &


What is the result of the logical OR operator (||) if one condition is true and the other is false?

a) True

b) False

c) 0

d) 1


Which operator is the logical NOT operator in Java?

a) !

b) &&

c) ||

d) ^


What is the output of the expression: !(5 > 3) in Java?

a) True

b) False

c) 2

d) Compilation error


What is the result of the expression: (10 > 5) && (7 < 3) in Java?

a) True

b) False

c) Compilation error

d) 0


Which logical operator inverts the result, making a true statement false and vice versa?

a) !

b) &&

c) ||

d) ^


What is the result of the expression: (6 >= 6) || (3 != 3) in Java?

a) True

b) False

c) Compilation error

d) 1


Which operator combines two conditions and evaluates to true only if both conditions are true?

a) ||

b) !

c) &&

d) ^


What is the output of the expression: !false && true in Java?

a) True

b) False

c) Compilation error

d) 0


Answers:


a) True

b) ||

a) True

a) !

a) True

b) False

a) !

a) True

c) &&

a) True

No comments:

Post a Comment

git commands MCQ

 Here are some multiple-choice questions (MCQs) on Git commands relevant for Selenium: 1. Which Git command is used to clone a remote reposi...