Question: All Java Statements 6. How many times does When is the class going to end? print? Note: this loop is OK. // Note that its

All Java Statements

6. How many times does "When is the class going to end?" print? Note: this loop is OK.

// Note that its legal to nest one loop inside another. The entire inner loop executes

// its appropriate number of times each time the outer loop is executed once.

int count1 = 1;

while (count1 <= 2)

{

int count2 = 1;

while (count2 <= 3)

{

System.out.println("When is the class going to end?");

count2++;

}

count1++;

} // your brief answer:

// 7. Your challenge: What does this loop print? Note: theres nothing to fix in this loop.

for (int k = 0; k < 100; k = k+1)

{

System.out.println(k);

}

Your brief answer:

// 8. How about this one (its also OK)?

for (int k = 0; k < 100; k = k+1)

{

System.out.println(k++); // k++ returns the original value of k, and then adds 1 to k

}

Your brief answer:

// 9. What is wrong with the following for loop? What is the output after it is fixed?

int k;

for (k = 0; k = 1; k++) // k++ returns the original value of k, and then adds 1 to k

{

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

}

Your brief answer:

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!