
JAVA for loops and while loops

Quiz
•
9th - 12th Grade
•
Medium
Used 110+ times
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct function of a for loop?
To check for conditions after executing the statements
To be a control flow statement that allows code to be executed repeatedly based on a given Boolean condition.
To determine a boolean variable as true or false.
To consume the initialization, condition and increment/decrement in one line thereby providing a shorter, easy to debug structure of looping.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is an Increment/ Decrement?
It initializes the variable in use.
It is used for updating the variable for next iteration.
It marks the start of a for loop.
It is used for testing the exit condition for a loop.
3.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
What is the output of the following code segment?
class forLoopDemo
{ public static void main(String args[])
{ // for loop begins when x=2
// and runs till x <=4
for (int x = 2; x <= 4; x++)
System.out.println("Value of x:" + x);
}
}
Value of x:2
Value of x:3
Value of x:4
Value of x:1
Value of x:2
Value of x:3
Value of x:2
Value of x:2
Value of x:4
Value of x:2
Value of x:3
Value of x:3
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the correct function of a while loop?
A control flow statement that allows code to be executed repeatedly based on a given Boolean condition.
To consume the initialization, condition and increment/decrement in one line
To initialize the variable in use.
To check for condition after executing the statements
5.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
What is the correct output for the following code segment?
class whileLoopDemo
{
public static void main(String args[])
{
int x = 1;
// Exit when x becomes greater than 4
while (x <= 4)
{
System.out.println("Value of x:" + x);
// Increment the value of x for
// next iteration
x++;
}
}
}
Value of x:1
Value of x:2
Value of x:4
Value of x:1
Value of x:2
Value of x:3
Value of x:1
Value of x:2
Value of x:3
Value of x:4
Value of x:2
Value of x:2
Value of x:3
Value of x:4
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What are 3 general types of loops in Java?
for loops, while loops and do loops
while loops, do loops and hit loops
kin loops, for loops and multi loops
for loops, while loops and multi loops
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What must the test be so that the following fragment prints out the integers 5 through and including 15?
for ( int j = 5; ________ ; j++ )
{
System.out.print( j + " " );
}
System.out.println( );
j<15
j<=16
j<16
j==15
Create a free account and access millions of resources
Similar Resources on Wayground
12 questions
Python Loops

Quiz
•
9th - 11th Grade
15 questions
PYTHON PROGRAMMING

Quiz
•
11th - 12th Grade
15 questions
Feedback Loops

Quiz
•
9th Grade - University
13 questions
C++ Loops

Quiz
•
9th - 12th Grade
13 questions
Positive and Negative Feedback Loops

Quiz
•
9th - 12th Grade
10 questions
Programming - Iteration, Basic Programming Constructs & Loop

Quiz
•
2nd - 12th Grade
12 questions
12 Handwriting Characteristics

Quiz
•
9th - 12th Grade
10 questions
Quiz 13 - For Loops

Quiz
•
11th Grade
Popular Resources on Wayground
50 questions
Trivia 7/25

Quiz
•
12th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
11 questions
Negative Exponents

Quiz
•
7th - 8th Grade
12 questions
Exponent Expressions

Quiz
•
6th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
20 questions
One Step Equations All Operations

Quiz
•
6th - 7th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade
Discover more resources for
50 questions
Trivia 7/25

Quiz
•
12th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
18 questions
"A Quilt of a Country"

Quiz
•
9th Grade
6 questions
RL.10.1 Cite Evidence

Quiz
•
10th Grade
10 questions
Characteristics of Life

Quiz
•
9th - 10th Grade
14 questions
Algebra 1 SOL Review #1

Quiz
•
9th Grade