Loop Study Exam Questions & Answers 2024/2025
If you want to iterate a loop a set number of times, which loop would be best to use? - ANSWERSFor Loop
What problem occurs in the following loop?
int i = 0;
while(i < 10){
Sln(i);
} - ANSWERSInfinite looping
How many times will i be p...
If you want to iterate a loop a set number of times, which loop would be best to use? - ANSWERSFor
Loop
What problem occurs in the following loop?
int i = 0;
while(i < 10){
System.out.println(i);
} - ANSWERSInfinite looping
How many times will i be printed?
for(int i = 0; i < 9; i++){
System.out.println(i);
} - ANSWERS9
If you wanted the following loop to iterate 10 times what should x be?
for(int i = 0; i < x; i += 2) - ANSWERS19
To end the loop when the user enters 0, what should replace x?
int input = 1;
do{
...
}while(x); - ANSWERSinput != 0
Each pass through a loop is called a(n) - ANSWERSiteration
, What's wrong?
while((i < 10) && (i > 26)) - ANSWERSthe condition will always be false
A continue statement causes the loop to - ANSWERSskip to the next iteration
i++; is equivalent to - ANSWERSi = i + 1;
What's wrong?
(int k = 2, k < 14, k++) - ANSWERSthe commas should be semicolons
What value is stored in num at the end of this looping?
for(num = 1; num <= 5; num++) - ANSWERS6
In a nested loop, which loop has the most passes? - ANSWERSthe innermost loop
Which looping process checks the condition at the end of the loop? - ANSWERSdo-while loop
If only one statement is made after a loop are brackets {} necessary? - ANSWERSNo
What's wrong?
for(int x = 1; x > 100; x++;) - ANSWERSThe final semicolon is not necessary
The purpose of a loop is to - ANSWERSrepeat an operation many times.
What is the output of the following:
public static void main(String[] args) {
Integer a=012, b;
for(b=0;b<=a;b++);
System.out.print(b);
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Bensuda. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for £6.50. You're not tied to anything after your purchase.