2. Programming Fundamentals

Control Structures — Quiz

Test your understanding of control structures with 5 practice questions.

Read the lesson first

Practice Questions

Question 1

Which of the following best describes the behavior of a nested 'for' loop with varying loop bounds in each iteration?

Question 2

Consider the following code: int sum = 0; for (int i = 1; i <= 4; i++) { for (int j = 1; j <= i; j++) { sum = sum + j; } } What is the final value of 'sum'?

Question 3

In a 'for' loop, which of the following can cause an infinite loop if not handled properly?

Question 4

What is the output of the following code? int x = 1; for (int i = 0; i < 4; i++) { if (i % 2 == 0) { x = x * 2; } else { x = x + 3; } } System.out.println(x);

Question 5

If a 'while' loop has multiple conditions combined with logical operators, when does the loop terminate?
Control Structures Quiz — GCSE Computer Science | A-Warded