
Introduction to While Loops
Quiz
•
Computers
•
9th - 12th Grade
•
Medium
Used 2+ times
FREE Resource
Enhance your content in a minute
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
8.
MULTIPLE SELECT QUESTION
5 mins • 1 pt
What should go in place of /* missing code */ so that the program will end when the number -1 is entered?
int val = scan.nextInt();
int total = 0;
while( /* missing code */) {
System.out.println("Please enter a number");
val = scan.nextInt();
total += val; }
val == -1;
val != - 1
val = -1
!(val == -1)
Similar Resources on Wayground
13 questions
Melody Tone
Quiz
•
9th Grade
10 questions
Alapismeretek
Quiz
•
7th - 12th Grade
10 questions
Scratch
Quiz
•
KG - Professional Dev...
10 questions
Network Security
Quiz
•
9th - 11th Grade
10 questions
What is a program slides(6:16)
Quiz
•
8th - 12th Grade
10 questions
ExamenHojasdecalculo
Quiz
•
10th Grade
12 questions
Sistemas de Información
Quiz
•
12th Grade
10 questions
BÀI KIỂM TRA GIỮA KÌ 2 - LỚP 3
Quiz
•
1st - 10th Grade
Popular Resources on Wayground
5 questions
This is not a...winter edition (Drawing game)
Quiz
•
1st - 5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
Identify Iconic Christmas Movie Scenes
Interactive video
•
6th - 10th Grade
20 questions
Christmas Trivia
Quiz
•
6th - 8th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
11 questions
How well do you know your Christmas Characters?
Lesson
•
3rd Grade
14 questions
Christmas Trivia
Quiz
•
5th Grade
20 questions
How the Grinch Stole Christmas
Quiz
•
5th Grade
