Java Assertions Quiz – 20 Questions with Answers
20 questions · 15 min · Medium
Test your knowledge of flow control in Java, including conditional statements, loops, switch statements, break, continue, and control flow techniques.
No sign-up needed · Last updated:
Score: 0 00:00
Create a free account to keep your scores and track your progress. It is optional.
20 questions · 15 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
A. To control the order in which program statements are executed
Flow control statements determine which statements execute, how many times they execute, and in what order.
A. if
The if statement executes a block of code when its Boolean condition evaluates to true.
A. else
The else block executes when the associated if condition evaluates to false.
A. if-else if-else
An if-else if-else chain allows multiple conditions to be evaluated in sequence.
A. switch
The switch statement provides multi-way branching based on the value of an expression.
A. break
In a traditional switch statement, break exits the switch after the matching case has executed.
A. for
A for loop combines initialization, a continuation condition, and an update expression in its syntax.
A. while
A while loop evaluates its condition before each iteration, so its body may execute zero times.
A. do-while
A do-while loop executes its body before checking the condition, so it always executes at least once.
A. Terminates the nearest enclosing loop
The break statement immediately terminates the nearest enclosing loop or switch statement.
A. Skips the remainder of the current iteration and proceeds with the next iteration
The continue statement skips the remaining statements in the current loop iteration and continues with the next iteration.
A. for-each loop
The enhanced for statement, commonly called the for-each loop, is used to iterate over arrays and Iterable objects.
A. Yes
Since 5 is greater than 3, the condition is true and the program prints Yes.
A. return
The return statement terminates execution of the current method and can return a value when the method requires one.
A. Java provides conditional statements, loops, and branching statements to control program execution
Java provides several flow control mechanisms, including if statements, switch statements, loops, break, continue, and return.