Mastering Java Loops

Mastering Java Loops

12th Grade

15 Qs

quiz-placeholder

Similar activities

Conjunctions

Conjunctions

9th Grade - University

20 Qs

Adverbial Clauses

Adverbial Clauses

12th Grade - University

10 Qs

Arduino

Arduino

12th Grade

14 Qs

Suffixes 2

Suffixes 2

9th - 12th Grade

10 Qs

1st, 2nd and 3rd GL

1st, 2nd and 3rd GL

12th Grade

15 Qs

Coding Basics

Coding Basics

12th Grade - University

20 Qs

Understanding Conditional Statements

Understanding Conditional Statements

11th Grade - University

15 Qs

Connectors - TYPES

Connectors - TYPES

10th Grade - University

12 Qs

Mastering Java Loops

Mastering Java Loops

Assessment

Quiz

English

12th Grade

Medium

Created by

Vignesh Rajkumar

Used 1+ times

FREE Resource

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code: for(int i=0; i<5; i++){ System.out.print(i); }?

56789

01234

0123

12345

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you declare a while loop in Java?

repeat (condition) { // code to execute }

for (condition) { // code to execute }

do while (condition) { // code to execute }

while (condition) { // code to execute }

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Write a while loop that prints numbers from 1 to 10.

i = 1 while i < 10: print(i) i += 1

i = 1 while i <= 10: print(i) i += 1

i = 0 while i < 10: print(i) i += 1

for i in range(1, 11): print(i)

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the 'break' statement in loops?

To exit a loop prematurely.

To continue to the next iteration of a loop.

To skip the current iteration of a loop.

To pause the execution of a loop temporarily.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Explain the difference between a for loop and a while loop.

For loop: fixed iterations; While loop: condition-based iterations.

For loop: condition-based iterations; While loop: fixed iterations.

For loop: used for recursion; While loop: used for iteration.

For loop: executes once; While loop: executes indefinitely.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code: for(int i=0; i<3; i++){ for(int j=0; j<2; j++){ System.out.print(i+j); }}?

011223

123

01223

0111223

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you control the execution of a loop using a condition?

Use a conditional statement to check a condition before each loop iteration.

Ignore the condition and run the loop indefinitely.

Use a loop without any conditions.

Always execute the loop a fixed number of times.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?