Question: 10. What is wrong with the following for loop? What is the output after it is fixed? for (int k =1, k == 20; k++)

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

for (int k =1, k == 20; k++) {}

Your brief answer:

// 11. What does this do-while loop print (its OK as-is)?

int k = 3;

do

{

System.out.print(k);

} while (k != 3);

Your brief answer:

// 12. What is wrong with the following do-while loop? What is the output after it is fixed?

do

{

System.out.println("This looks correct")

} while {true};

Your brief answer:

// 13. assume String s = "0123456789"; how would you write a for-each loop that prints the characters in s, but only those that represent even numbers? A String for-each loop looks like this: for (char c : s.toCharArray()) { } // puts each character from s, one at a time, into variable c

// then you can use the char variable c inside the curly braces and only print the even ones

Your answer below copy the for-each loop and add your statements inside its curly braces:

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!