Boolean Logic & Conditional Statements
What is the result of the expression (true || false)
in Java?
Null
True
Error
False
How does creating multiple classes in a Java program enhance modularity?
It removes the necessity to write constructors for objects.
It automatically parallelizes the code for faster execution on multi-core processors.
It separates concerns by grouping related variables and behaviors together.
It reduces memory usage by sharing methods among different classes.
For debugging purposes, which statement ensures that only when variables 'a' and 'b' have values larger than zero will it return true?
(a > 0 && b > 0)
If variables p
, q
, and r
are all boolean with different values, which expression potentially results in a different value compared to others when evaluated?
!(p || q) && r
(!p && !q) || r
!(p && q) || r
What is the purpose of nested conditionals in programming?
To improve code performance
To simplify code logic
To evaluate multiple conditions within an if statement
To combine multiple if statements into one
In what case does the following statement return false? ""
num ≤ threshold but flag’s value isn’t known
flag is false and num ≤ threshold
The statement always returns true
flag’s value isn’t known but num > threshold
Which of the following expressions would correctly evaluate to true if the integer variable 'score' is greater than or equal to 90 and less than or equal to 100?
( (score => 90) && (score =! 100) )
( (score >= 90) && (score <= 100) )

How are we doing?
Give us your feedback and let us know how we can improve
Which expression evaluates whether a string str has an odd length and includes exactly one of its characters on its seventh index?
str.length()%2==0 || str.charAt(6)!=str.charAt(7)
(str.length()<7) && !(str.charAt(6)==str.charAt(7))
str.length()>7 && str.charAt(6)!=str.charAt(7)
str.length()%2==0 && str.charAt(6)==str.charAt(7)
To confirm during testing that both variables 'alpha' and 'beta' have non-negative values before proceeding further in code execution, what statement would you use?
(alpha \geq 0) && (beta \geq 0)
Which best exemplifies how method overloading contributes to modularity in Java?
Saving storage space by allowing one method name to reference multiple implementations at once.
Providing two methods with the same name but different parameters to perform similar tasks efficiently.
Giving each method a unique name based on its functionality to avoid confusion during calling procedures.
Increasing processing speed by loading methods into memory only when they are called.