Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What does the break statement do in a loop?
Think about leaving a game midway.
What happens when continue is executed?
Consider if you're overlooking a specific snack among many.
What does the break statement do?
Consider it like leaving a class.
What will be printed below?
for (int i = 1; i <= 5; i++) { if (i == 3) continue; System.out.println(i); }
Think about which numbers you're not seeing in the output.
Write a Java program that creates a loop and utilize both break and continue to demonstrate their usages. What should the loop output?
Use both statements to see how they affect the output.
Create a method that calculates Fibonacci numbers until a specified limit, using return to exit once the limit is exceeded.
Think of how Fibonacci sequences grow rapidly - the loop needs to recognize when to stop.
7 more questions in this section. Enroll free to practise them all.
Enroll free