Trace the Code
Loop Logic
If / Else Reasoning
Debug the Idea
Vocabulary & Concepts
100

x = 5

x = x + 3

print(x)

What will be printed?

what is 8

Explanation:

The variable x starts at 5, then 3 is added, making the final value 8.

100

for (int i = 0; i < 5; i++) {

    System.out.print(i + " ");

}

How many numbers are printed?

What is 5

Explanation:

The loop runs while i is 0 through 4, which is five iterations.

100

int num = 7;

if (num > 5) {

    System.out.println("High");

} else {

    System.out.println("Low");

}

What is printed?

What is High

Explanation:

Since 7 is greater than 5, the if condition is true.

100

int x;

System.out.println(x);


What is wrong?

What is x is not initialized.

Explanation:

Java requires local variables to be given a value before they are used.

100

What is a variable in Java?

What is A named storage location for data.

Explanation:

Variables store values that can change while a program runs.

200

int a = 2;

int b = 4;

a = b - a;

b = a + b;

System.out.println(a + " " + b);

What is printed?

what is 2,6

Explanation: First a becomes 2 (4 − 2), then b becomes 6 (2 + 4).

200

int count = 0;

for (int i = 1; i <= 10; i++) {

    if (i % 2 == 0) {

        count++;

    }

}

System.out.println(count);

What is printed?

What is 5

Explanation:

There are five even numbers between 1 and 10, so count increases five times.

200

int score = 85;

if (score >= 90) {

    System.out.println("A");

} else if (score >= 80) {

    System.out.println("B");

} else {

    System.out.println("C");

}

What letter grade is printed?

What is B

Explanation:

The score is not high enough for an A but meets the condition for a B.

200

for (int i = 0; i <= 5; i--) {

    System.out.println(i);

}

What is wrong?

What is The loop will never stop.

Explanation:

i is decreasing while the condition checks if it is less than or equal to 5, causing an infinite loop.

200

What does a for loop do?

What Is Repeats a block of code a specific number of times.

Explanation:

A for loop uses initialization, condition, and update steps to control repetition.

300

int total = 0;

for (int i = 1; i <= 4; i++) {

    total += i * 2;

}

System.out.println(total);

What is printed?

What Is 20

Explanation:

The loop runs 4 times and adds 2, 4, 6, 8 to total, which sums to 20.

300

int sum = 0;

int i = 5;

while (i > 0) {

    sum += i;

    i -= 2;

}

System.out.println(sum);

What is printed?

What is 9

Explanation:

The loop adds 5 + 3 + 1 before stopping, resulting in a total of 9.

300

int x = 10;

int y = 20;


if (x > 5 && y < 15) {

    System.out.println("A");

} else if (x <= 10 || y >= 20) {

    System.out.println("B");

} else {

    System.out.println("C");

}

What is printed?

What is B

Explanation:

The first condition fails, but the else if is true because x <= 10 and y >= 20.

300

int[] nums = {1, 2, 3};

System.out.println(nums[3]);


What is wrong?

What is The index is out of bounds.

Explanation:

Arrays start at index 0, so the last valid index is 2, not 3.

300

What is the difference between == and .equals() in Java?

What is  == compares memory references, while .equals() compares values.

Explanation:

For objects like strings, .equals() checks the actual content, not the location in memory.