
Introduction to While Loops
Computers
9th - 12th Grade
Used 2+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
8 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
5 mins • 1 pt
What is the output of the following code?
int x = 0;
while (x < 4) { x = x + 1;}
System.out.println("x is " + x);
0
1
3
4
2.
MULTIPLE CHOICE QUESTION
5 mins • 1 pt
What will be displayed when the following code is executed?
6 3 0
6 3
3 0
0
3.
MULTIPLE CHOICE QUESTION
5 mins • 1 pt
What will be the output of the following code?
int x = 0;
while( x > 0 ) {
System.out.print( x + " ");
x++; }
0 0 0 0 0
1 2 3 4 5
0 1 2 3 4
0 1 2 3 4 5 ... infinite loop
4.
MULTIPLE CHOICE QUESTION
5 mins • 1 pt
What is the output of the code?
int num = 1;
while ( num < 10 ) {
num += 2;
System.out.print( num + " "); }
3 5 7 9 11
3 5 7 9
1 3 5 7 9 11
1 3 5 7 9
5.
MULTIPLE CHOICE QUESTION
5 mins • 1 pt
What should go in place of /*missing code*/ so that the program only accepts the name "Bill" as the correct username?
String name = scan.next();
while( */ missing code */ ) {
System.out.print("Please enter the correct username: ");
name = scan.next();
}
//username is correct
System.out.println("Welcome Bill!");
name == "Bill"
name != "Bill"
name.equals("Bill")
!(name.equals("Bill"))
6.
MULTIPLE CHOICE QUESTION
5 mins • 1 pt
What is the value of sum at the completion of the code?
int val = 0;
int sum = 0;
while (num <= 8 ) {
sum += num;
num++; }
sum = 36
sum = 28
sum = 42
infinite loop
7.
MULTIPLE CHOICE QUESTION
5 mins • 1 pt
What is the value for x at the completion of the program?
int x = 1;
while( x < 100 ) {
x = x + x;
System.out.print(x + " "); }
64
128
99
100
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
10 questions
Parcial-Dibujo
Quiz
•
12th Grade
10 questions
Quiz TLJ - VoIP
Quiz
•
12th Grade
10 questions
Unit 4 Advanced AP CSP
Quiz
•
9th - 12th Grade
10 questions
Cybersecurity Quiz
Quiz
•
12th Grade
10 questions
Ciência de Dados - Algoritmos de Las Vegas II.
Quiz
•
12th Grade
10 questions
10° Bimestral informática 3° periodo
Quiz
•
10th Grade
12 questions
Examen final algoritmo
Quiz
•
11th Grade
10 questions
Les variables sous Python
Quiz
•
10th - 12th 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
54 questions
Analyzing Line Graphs & Tables
Quiz
•
4th 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