B4 - The for Statement

B4 - The for Statement

University

10 Qs

quiz-placeholder

Similar activities

Object Oriented Programming Quizz

Object Oriented Programming Quizz

University

10 Qs

Java Basics – Day 1 Quiz

Java Basics – Day 1 Quiz

University

10 Qs

CSC126 Quick Exercise 3-1

CSC126 Quick Exercise 3-1

University

13 Qs

Python Review Module 14 - Recursion

Python Review Module 14 - Recursion

University

10 Qs

Multiple-Choice Quiz on Java Arrays

Multiple-Choice Quiz on Java Arrays

University

15 Qs

Praktisi Mengajar - Java Test

Praktisi Mengajar - Java Test

University

10 Qs

Java Programming Quiz

Java Programming Quiz

University

13 Qs

Mastering Python Loops

Mastering Python Loops

University

10 Qs

B4 - The for Statement

B4 - The for Statement

Assessment

Quiz

Other

University

Easy

Created by

Ahmetcan türk

Used 3+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What are the three general types of looping structures?

counting loop, sentinel-controlled loop, and result-controlled loop.

infinite loop, counting loop, nested loop

while loop, for loop, do loop

count up loop, count down loop, infinite loop

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following program fragment?

int j;

for ( j = 0; j < 5; j++ )

{

System.out.print( j + " " );

}

System.out.println( );

1 2 3 4 5

0 1 2 3 4

0 1 2 3 4 5

j j j j j

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code fragment?

int j;

for ( j = 10; j > 5; j-- )

{

System.out.print( j + " " );

}

System.out.println( );

10 11 12 13 14 15

9 8 7 6 5 4 3 2 1 0

10 9 8 7 6 5

10 9 8 7 6

4.

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?

int j;

for ( j = 5; ________ ; j++ )

{

System.out.print( j + " " );

}

System.out.println( );

j<15

j<=16

j<16

j==15

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What must the change be so that the following fragment prints out the even integers 0 2 4 6 8 10?

int j;

for ( j = 0; j <= 10; _______ )

System.out.print( j + " " );

System.out.println( );

j+2

j = j+2

j++++

++j++

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What must the initialization be so that the following fragment prints out the integers -3 -2 -1 ?


int j;

for ( _______ ; j < 0; j++ )

System.out.print( j + " " );

System.out.println( );

j = 0

j < 0

j = -3

j = -4

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code fragment?

int j;

for ( j = 5; j > -5; j-- )

System.out.print( j + " " );


System.out.println( );

-5 -4 -3 -2 -1 0

5 4 3 2 1 0

5 4 3 2 1 0 -1 -2 -3 -4 -5

5 4 3 2 1 0 -1 -2 -3 -4

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?