Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions

Question

5. Wyeth Pharmaceuticals

Answered: 1 week ago