Unit 3: Boolean Expressions and If Statements

Showing 20 of 23 questions

Q1
MULTIPLE_CHOICEEasy

What is the output of the following code?

Q2
MULTIPLE_CHOICEMedium

What is the output of the following code?

Q3
MULTIPLE_CHOICEHard

Which of the following boolean expressions is equivalent to !(x >= 5 && x < 20)?

Q4
MULTIPLE_CHOICEMedium

What is the output of the following code?

Q5
MULTIPLE_CHOICEHard

What is the output of the following code?

Q6
MULTIPLE_CHOICEMedium

What is the output of the following code?

Q7
MULTIPLE_CHOICEHard

Given the method below, what is returned when isValid(15) is called?

Q8
MULTIPLE_CHOICEEasy

What is the output of the following code?

Q9
MULTIPLE_CHOICEMedium

What is the output of the following code?

Q10
MULTIPLE_CHOICEEasy

Which of the following boolean expressions is equivalent to !(a && b)?

Q11
MULTIPLE_CHOICEHard

What is the output of the following code?

Q12
MULTIPLE_CHOICEEasy

What is the value of !(true && false)?

Q13
MULTIPLE_CHOICEMedium

What is printed?\nint x = 15;\nif (x > 20) System.out.print("A");\nelse if (x > 10) System.out.print("B");\nelse System.out.print("C");

Q14
MULTIPLE_CHOICEHard

Which expression is equivalent to !(a && b)?

Q15
MULTIPLE_CHOICEHard

Given: int x = 0; if (x != 0 && 10/x > 2) ... What happens?

Q16
MULTIPLE_CHOICEMedium

What does == compare when used with two object references?

Q17
MULTIPLE_CHOICEMedium

What is the output?\nint x = 5, y = 10;\nif (x > 3) if (y < 8) System.out.print("A"); else System.out.print("B");

Q18
MULTIPLE_CHOICEEasy

The conditional expression (x > 0) ? "positive" : "non-positive" is equivalent to:

Q19
MULTIPLE_CHOICEMedium

For what value of x is the expression (x > 5 && x < 10) true?

Q20
MULTIPLE_CHOICEHard

Which is equivalent to !(a || b)?

Advertisement