
JAVA for loops and while loops
9th - 12th Grade
Used 118+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
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
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
15 questions
BIOCATALYSIS
Quiz
•
10th Grade - Professi...
12 questions
World Science Day!
Quiz
•
6th - 10th Grade
15 questions
Expressing O and T
Quiz
•
10th - 12th Grade
13 questions
Unit 8 Test Corrections
Quiz
•
9th Grade
10 questions
Chapter 3 Test Review (Big Ideas)
Quiz
•
9th Grade
10 questions
Find derivative and gradient of a tangent
Quiz
•
12th Grade
14 questions
AP Physics C Intro to Electrostatics
Quiz
•
11th - 12th Grade
10 questions
Geometric Vectors - Y11 MATHS
Quiz
•
11th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
Discover more resources for
20 questions
El Verbo IR Practice
Quiz
•
9th Grade
20 questions
-AR -ER -IR present tense
Quiz
•
10th - 12th Grade
10 questions
Understanding Meiosis
Interactive video
•
6th - 10th Grade
20 questions
Graphing Inequalities on a Number Line
Quiz
•
6th - 9th Grade
15 questions
Main Idea and Supporting Details.
Quiz
•
4th - 11th Grade
10 questions
Theme
Quiz
•
9th Grade
20 questions
Cell Organelles
Quiz
•
10th Grade
12 questions
Exponential Growth and Decay
Quiz
•
9th Grade