Unit 3: Boolean Expressions and if Statements

What will be the output of the following code?

int x = 10;
if (x > 5) {
    System.out.println("x is greater than 5");
} else {
    System.out.println("x is not greater than 5");
}

a) x is not greater than 5
b) x is greater than 5
c) No output
d) Compile-time error

Answer: b) x is greater than 5

What is the result of the boolean expression !(false || true)?
a) true
b) false
c) null
d) Compile-time error

Answer: b) false

Which of the following expressions will evaluate to true?
a) (5 > 10) && (3 < 4)
b) (5 > 10) || (3 < 4)
c) (5 < 10) && (3 > 4)
d) (5 < 10) || (3 > 4)

Answer: b) (5 > 10)   (3 < 4)