Boolean Logic & Conditional Statements
What is the output of the following code snippet if the integer variable score is 85?
java
if (score >= 90) {
System.out.println("A");
} else if (score >= 80) {
System.out.println("B");
} else if (score >= 70) {
System.out.println("C");
} else {
System.out.println("F");
}
F
A
C
B
What would be printed by this Java code segment?
int score =85; if(score >=90){ System.out.println("A"); }else{ System.out.println("B"); }
C
A
No Output
B
In a Java program, what will happen if all conditions in an "if-else-if" ladder are false?
The first "if" block will execute by default.
The last "else-if" block will execute regardless of its condition.
The "else" block at the end will execute, if present.
All "else-if" blocks will execute one after another.
In what scenario would an inner 'else-if' block be executed when nested inside another 'if-else' structure?
When all other outer conditions fail.
When any previous 'if' or 'else-if' conditions succeed.
When its specific condition evaluates as true regardless of outer conditions.
When its outer 'if' condition fails and its own condition succeeds.
Which of these changes would correctly cause an output of “Average” when inputting a speed value of ‘50’ into this speed assessment code?
Change ‘speed’<100 to ‘speed’<75 in first condition and add new condition 'else-if(speed>50)' before final 'else'.
Replace final “Slow’ with “Average”
Add additional check ’speed==50’in first ‘else-if’
Remove ‘&& speed<=100’ from second condition only.
Assuming there's an integer variable age, which conditional structure would correctly print "Adult" when age is at least eighteen, otherwise "Minor"?
if(age >17) {System.out.println("Minor");}else{System.out.println("Adult");}
if(age ==18) {System.out.println("Adult");}else{System.out.println("Minor");}
if(age >=18) {System.out.println("Adult");}else{System.out.println("Minor");}
if(age <=18) {System.out.println("Adult");}else{System.out.println("Minor");}
Which outcome best represents a potential downside when excessively using nested else-if structures to navigate complex decision trees within an algorithm?
Reduced memory usage as no extra space is required for alternates.
Increased execution speed due to better branch prediction by processors.
Enhanced readability through clear delineation of decision branches.
Decreased maintainability due to difficulty understanding and updating code logic.

How are we doing?
Give us your feedback and let us know how we can improve
Given a complex system with multiple levels of inheritance and polymorphism, which statement correctly identifies when a superclass constructor gets called during object creation?
Superclass constructors are never called directly; they are only invoked through subclass methods using super keyword.
Subclass constructors must explicitly call superclass constructors using super().
Superclass constructors are called before sub-class constructors during object instantiation starting from the topmost parent down.
Superclass constructors are called after all subclass constructors have finished executing.
What keyword should follow an ‘if’ block to provide an alternative path when the ‘if’ condition is not met?
except
else
elif
otherwise
Which method returns the largest divisor between 1 and 10 that a number is divisible by?
largestDivisorLessThanTen
isDivisibleByTen
isLeap
checkLeapYear