Page 107 - 2617_JSSPS_C-7
P. 107
When you enter the value 8, none of the cases will be matched. Hence, the default case will be executed
and the output “Invalid day number” will be displayed on the terminal.
Topic Flashback 21 st Century
Skills #Critical Thinking
Define the following statements:
1. if
2. if...else
3. if...else...if
LOOPING STATEMENTS
Looping statements are the control flow statements that allow us to repeatedly execute a set of
statements for a given number of times. These are also called iteration statements or loops. Java
provides three kinds of looping statements, which are as follows:
while
do-while
for
However, the for loop is more commonly used as compared to the while and do-while loops.
Let us learn about these in detail.
The while Loop
The while loop is a flow control statement in Java. It is used to execute a block of statements repeatedly
until a given condition becomes false. In a while loop, the condition is evaluated first and if it returns
true, then the statements inside the loop are executed.
Java Programming 105

