CMP128 Java Ch. 04 Loops Pt. 2
Flashcard
•
Computers
•
University
•
Practice Problem
•
Hard
Wayground Content
FREE Resource
Student preview

10 questions
Show all answers
1.
FLASHCARD QUESTION
Front
Which looping construct is illustrated below?
for (int i=0; i<5; i++)
{
System.out.println ("The square of " + i + " is: " + (i*i));
}
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.
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
Understanding Quadratic Equations
Flashcard
•
University
10 questions
Teoria Cognitiva da Aprendizagem Multimédia - 10 Princípios
Flashcard
•
KG
7 questions
Importance of Breakfast
Flashcard
•
12th Grade
12 questions
Konsep Statistika Parametrik dan Non-Parametrik
Flashcard
•
University
12 questions
The Business Telephone Etiquette
Flashcard
•
12th Grade
8 questions
Descobre a causa!
Flashcard
•
KG - University
5 questions
Brain Teasers
Flashcard
•
KG - University
10 questions
Business Jargon Flashcard
Flashcard
•
Professional Development
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
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
20 questions
Figurative Language Review
Quiz
•
6th Grade
Discover more resources for Computers
4 questions
Conflict Resolution
Lesson
•
KG
20 questions
Place Value
Quiz
•
KG - 3rd Grade
20 questions
CVC Words
Quiz
•
KG - 1st Grade
24 questions
CKLA Unit 5 assessment K
Quiz
•
KG
10 questions
STAAR Review - Editing & Revising Clusters
Quiz
•
KG
10 questions
Reflexive Pronouns
Quiz
•
KG - 5th Grade
10 questions
Long i- igh, ie, and y Quiz
Quiz
•
KG - 3rd Grade
12 questions
Quarter Past, Half Past, and Quarter To
Quiz
•
KG - 12th Grade