Introduction to While Loops

Introduction to While Loops

9th - 12th Grade

8 Qs

quiz-placeholder

Similar activities

Computer Security

Computer Security

8th - 10th Grade

10 Qs

Jaringan Komputer / AIJ

Jaringan Komputer / AIJ

11th Grade

10 Qs

SISTEM KOMPUTER KLS 9

SISTEM KOMPUTER KLS 9

9th Grade

10 Qs

WAN Sesi 1

WAN Sesi 1

1st Grade - University

10 Qs

Quiz #2 ETEC 486 | Spr. 16

Quiz #2 ETEC 486 | Spr. 16

KG - University

10 Qs

ofimatica

ofimatica

1st - 10th Grade

10 Qs

ukuran data

ukuran data

1st - 12th Grade

10 Qs

Informática 903 Segundo Trimestre- 2024

Informática 903 Segundo Trimestre- 2024

9th Grade

10 Qs

Introduction to While Loops

Introduction to While Loops

Assessment

Quiz

Computers

9th - 12th Grade

Medium

Used 2+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Media Image

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)