Which looping construct is illustrated below?
for (int i=0; i<5; i++)
{
System.out.println ("The square of " + i + " is: " + (i*i));
}
CMP128 Java Ch. 04 Loops Pt. 2

Flashcard
•
Computers
•
University
•
Hard
Quizizz Content
FREE Resource
Student preview

10 questions
Show all answers
1.
FLASHCARD QUESTION
Front
Back
A count-controlled quantifiable pre-test loop
2.
FLASHCARD QUESTION
Front
Which looping construct is illustrated below?
int num = 1;
char keepSquaring = 'Y';
do
{
System.out.println ("The square of " + num + " is: " + (num*num) + "\n");
num++;
System.out.print("Would you like to square another number? (Y/N): ");
keepSquaring = keyboard.nextLine().charAt(0);
}
while (keepSquaring == 'Y' || keepSquaring == 'y');
Back
Event-driven qualifiable Post-Test Loop
3.
FLASHCARD QUESTION
Front
Which looping construct is illustrated below?
int num = 1;
char keepSquaring = 'Y';
while (keepSquaring == 'Y' || keepSquaring == 'y')
{
System.out.println ("The square of " + num + " is: " + (num*num) + "\n");
num++;
System.out.print("Would you like to square another number? (Y/N): ");
keepSquaring = keyboard.nextLine().charAt(0);
}
Back
Event-driven qualifiable Pre-Test Loop
4.
FLASHCARD QUESTION
Front
What is wrong with the following loop?
int num = 1;
char keepSquaring = 'Y';
while (keepSquaring == 'Y' || keepSquaring == 'y')
{
System.out.println ("The square of " + num + " is: " + (num*num) + "\n");
num++;
Back
It is missing an update statement, so the loop is infinite.
5.
FLASHCARD QUESTION
Front
What is wrong with the following loop?
for (int i=0; i>5; i++)
{
System.out.println ("The square of " + i + " is: " + (i*i) + "\n");
}
Back
This loop will never execute the loop body because the counter variable starts at 0 and immediately fails the test of >5.
6.
FLASHCARD QUESTION
Front
What is wrong with the following loop?
for (int i=10; i>0; i++)
{
System.out.println ("The square of " + i + " is: " + (i*i) + "\n");
}
Back
It creates an infinite loop because i will never be less than or equal to 0.
7.
FLASHCARD QUESTION
Front
What is wrong with the following looping structure?
for (int i=0; i<5; i++)
{
System.out.println ("The square of " + i + " is: " + (i*i) + "\n");
}
Back
Nothing. It is perfect.
Create a free account and access millions of resources
Similar Resources on Quizizz
10 questions
Flashcard1-Intro-to-Java

Flashcard
•
University
10 questions
Arrays

Flashcard
•
10th - 12th Grade
10 questions
Ôn tập chủ đề F

Flashcard
•
KG
7 questions
Demo Flashcardizz_gestes de base

Flashcard
•
Professional Development
11 questions
Basic Java Programming Pre-test

Flashcard
•
11th Grade
13 questions
Data Types and Format Specifiers in C

Flashcard
•
University
3 questions
Java Classes & Objects

Flashcard
•
University
12 questions
Topic 1 C++ Programming

Flashcard
•
12th Grade
Popular Resources on Quizizz
15 questions
Character Analysis

Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing

Quiz
•
9th - 12th Grade
10 questions
American Flag

Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension

Quiz
•
5th Grade
30 questions
Linear Inequalities

Quiz
•
9th - 12th Grade
20 questions
Types of Credit

Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25

Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers

Quiz
•
6th - 8th Grade
Discover more resources for Computers
10 questions
Identifying equations

Quiz
•
KG - University
15 questions
Music 2016

Quiz
•
KG - 12th Grade
44 questions
logos

Quiz
•
KG - University
20 questions
Disney Characters

Quiz
•
KG
20 questions
Kids shows

Quiz
•
KG
20 questions
Guess that Disney

Quiz
•
KG - 5th Grade
20 questions
Cartoon Characters!

Quiz
•
KG - 5th Grade