Question: Question 1 Identify the true statements regarding Java loops. Select ALL that apply. Question options: A while loop might not run at all. For loops

Question 1

Identify the true statements regarding Java loops. Select ALL that apply.

Question options:

A while loop might not run at all.

For loops are more susceptible to endless loop coding errors than while loops.

A do-while loop always runs at least once.

Loops can be nested in other loops to any depth as desired.

While loops are best when the number of loop iterations can be predetermined.

Question 3

In which instance can a loop not require braces?

Question options:

when only one statement is to be repeated

when the number of iterations can be predetermined

when the loop is a do-while loop

when the number of iterations cannot be predetermined

Question 5

int n;

for(n = 8; n < 30; n += 5) {

//

}

System.out.print(n);

What is printed when the loop above has finished?

Question options:

Nothing. Compilation fails.

31

32

33

Question 6

4. for(int n = 0; n <= 12; n++) {

5. System.out.print(n + " ");

6. }

7. System.out.println(n);

What is the output of line 7?

Question options:

12

13

14

Nothing. Compilation fails

Question 7

for(int i = 0; i < 6; i++) {

for(int j = 1; j <= 5; j++) {

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

}

System.out.println();

}

What is printed by the third iteration of the outer loop?

Question options:

3 4 5 6 7

2 3 4 5 6

3 5 7 9 11

None of these are correct.

Question 9

int z = 2, sum = 0;

while (z < 9) {

z++;

sum = sum + z;

}

System.out.print(sum);

What is the output?

Answer:
Question 10

int b = 0, sum = 0;

while (b < 6) {

++b;

if(b % 2 == 0)

continue;

b++;

sum = sum + b;

}

System.out.print(sum);

What is the output?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!