Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

Which of the following is a valid for loop syntax in Java?

View

What is the output of the following code?

View

How many times will the following loop execute?

View

What is the difference between while and do-while loops?

View

What will be the output of the following code?

View

Which loop is guaranteed to execute at least once?

View

What will happen if the condition in a while loop is always true?

View

Which of the following is a correct way to exit a loop?

View

What is the output of the following code?

View

In a for loop, which part is executed only once?

View

Which of the following is a valid for loop syntax in Java?

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

What is the output of the following code?

for (int i = 0; i < 3; i++) { System.out.print(i + " "); }

0 1 2
0 1 2 3
1 2 3
0 1 2 3

How many times will the following loop execute?

int i = 0; while (i < 5) { i++; }

5
4
6
0

What is the difference between while and do-while loops?

do-while always executes at least once
while loop does not have a condition
while is faster than do-while
There is no difference

What will be the output of the following code?

int count = 0; for (int i = 0; i < 5; i++) { count++; } System.out.println(count);

0
5
4
10

Which loop is guaranteed to execute at least once?

for
while
do-while
none

What will happen if the condition in a while loop is always true?

The loop will run indefinitely
The loop will execute once
The loop will execute twice
It will throw an error

Which of the following is a correct way to exit a loop?

stop;
exit;
break;
return;

What is the output of the following code?

int j = 1; for (int i = 1; i <= 5; i++) { j *= i; } System.out.println(j);

120
60
5
15

In a for loop, which part is executed only once?

Initialization
Condition
Increment/Decrement
All parts are executed once