Working with Decision-making Statement in Java • 89
Explanation: There is no break statement in case 1, so both case 1 and case 2 are assumed to be true and
so is the output. In fact, due to the absence of break statement in the second case, rest of the statements are
considered part of the second case till a break is not found. Break in case 2 causes control to come out from
switch. If break were not in case 2 also then default would have got executed too.
4.7 INTRODUCTION OF LOOPS
Looping is a process in which a set of statements are executed repeatedly for a fi nite or infi nite number
of times. Java provides three ways to perform looping ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.