OK below goes: 1) What is ns after the complying with for loop?int y = 0;for (int i = 0; iy += i;}A) 10 9 C) 11 D) undefinedANSWER IS D___________________________________________________________2) What is the number of iterations in the complying with loop:for (int i = 1; ns // iteration}A) n n + 1 C) n - 1 D) 2*nANSWER IS A________________________________________________________3) after the proceed outer explain is enforcement in the following loop, i m sorry statement is executed?outer:for (int i = 1; ns inner:for (int j = 1; j if (i * j > 50)continue outer;System.out.println(i * j);}}next:A) The statement labeled next. The regulate is in the within loop, and the next iteration of the inner loop is executed.C) The control is in the external loop, and also the next iteration that the outer loop is executed.D) The regime terminates.ANSWER IS C_______________________________________________________________4) How many times will certainly the following code publish "Welcome to Java"?int counting = 0;while (count System.out.println("Welcome to Java");count++;}A) 0 9 C) 10 D) 11 E) 8ANSWER IS D5) What is the output for y?int y = 0;for (int ns = 0; iy += i;}System.out.println(y);A) 11 10 C) 12 D) 45 E) 13ANSWER IS D___________________________________________________________6) you can constantly convert a for loop to a while loop. A) true falseANSWER IS A________________________________________________________7) What is 1.0 + 1.0 + 1.0 == 3.0? A) true falseC) over there is no guarantee that 1.0 + 1.0 + 1.0 == 3.0 is true.ANSWER IS C__________________________________________________________8) analyze the following code.int x = 1;while (0 System.out.println(x++);A) The loop runs for ever. The password does not compile because (0 parentheses.C) The numbers 2 come 100 room displayed.D) The code does not compile due to the fact that the loop human body is not in the braces.E) The number 1 come 99 space displayed.ANSWER IS B______________________________________________________________9) girlfriend can always convert a while loop to a because that loop. A) true false29) The if loop and also the do loop are identical in your expressive power; in various other words, you canrewrite a if loop using a execute loop, and also vice versa.ANSWER IS A________________________________________________________________10)A) true falseANSWER IS A___________________________________________11) What balance ~ the adhering to code is executed?int balance = 10;while (balance >= 1) if (balance balance = balance - 9;A) The loop walk not finish -1C) 2D) 1E) 0ANSWER IS A_____________________________________________________12) What the output of the complying with code:for ( ; ; )System.out.println("Welcome to Java");A) prints out Welcome to Java one time. prints the end Welcome to Java forever.C) prints the end Welcome to Java two times. D) does not print anything.ANSWER IS B__________________________________________________________13) i think x is 0. What is the calculation of the adhering to statement?if (x > 0)printf("x is greater than 0");else if (x printf("x is much less than 0");elseprintf("x equates to 0");A) x equates to 0 x is higher than 0C) x is less than 0 D) NoneANSWER IS B____________________________________________________________14) What is y after the following for loop statement is executed?int y = 0;for (int i = 0; ns y += 1;}A) 12 10 C) 11 D) 9___________________________________________________15) The aspects inside the for loop regulate are separated using semicolons rather of commas. 34)A) true falseANSWER IS A_______________________________________________________16) What the calculation of the following code:for ( ; false ; )System.out.println("Welcome come Java");A) prints out Welcome to Java one time. prints out Welcome come Java forever.C) walk not publish anything. D) prints out Welcome come Java two times.ANSWER IS C_______________________________________________________17) A variable asserted in the because that loop control can be used after the loop exits. 36)A) true falseANSWER IS B________________________________________18) A continue statement have the right to be used only in a loop. A) true falseANSWER IS A_______________________________________________________19) What is the output of the complying with fragment?int i = 1;int j = 1;while (i i++;j = j * 2;}System.out.println(j);A) 16 64 C) 32 D) 4 E) 88ANSWER IS A20) friend can always write a routine without making use of break or continue in a loop. A) true falseANSWER IS A___________________________________________________________21) What is the value of balance ~ the following code is executed?int balance = 10;while (balance >= 1) if (balance balance = balance - 9;A) 1 2 C) -1 D) 0ANSWER IS A__________________________________22) analysis the following code.double amount = 0;for (double d = 0; d d += 0.1;}A) The program has actually a syntax error due to the fact that the control variable in the because that loop can not be of thedouble type. The regime compiles and also runs fine.C) The regimen compiles but does no stop because d would constantly be less than 10.D) The program has actually a syntax error due to the fact that the adjustment statement is not correct in the because that loop.ANSWER IS B______________________________________23) which of the complying with expression yields an integer between 0 and 100, inclusive? 42)A) (int)(Math.random() * 100) (int)(Math.random() * 101)C) (int)(Math.random() * 100 + 1) D) (int)(Math.random() * 100) + 1ANSWER IS B_____________________________________________________24) In a for statement, if the continuation condition is blank, the condition is suspect to it is in ________. A) true false__________________________________________________________25) What is the calculation of the following fragment?for (int ns = 0; ns if (i % 4 == 1)System.out.print(i + " ");}A) 1 3 5 7 9 11 13 1 3 5 7 9 11 13 15C) 1 5 9 13 16D) 1 5 9 13E) 1 4 8 12ANSWER IS D____________________________________________________26) A rest statement deserve to be used only in a loop.
You are watching: Which of the loop statements always have their body executed at least once?
See more: 28 Euros To Dollars (Usd) - 28 Eur To Usd Or Convert 28 Euro In Us Dollar
4A) true falseANSWER IS B________________________________________________--27) intend cond1 is a Boolean expression. When will this while condition be true?while (cond1) ...A) in instance cond1 is true constantly falseC) in case cond1 is false D) constantly trueANSWER IS C___________________________________________________________28) i m sorry of the following loops to produce the following output? (choose all that apply)1 2 3 4 1 2 3 1 2 1(I)for (int i = 5; i > 0; i--) for (int j = 1; j System.out.print(j + " ");System.out.println();(II)for (int ns = 1; i for (int j = 1; j System.out.print(j + " ");System.out.println();}(III)int ns = 0;while (i because that (int j = 1; j System.out.print(j + " ");System.out.println();i++;}(IV)int i = 5;while (i > 0) for (int j = 1; j System.out.print(j + " ");System.out.println();i--;A) (II) (IV) C) (I) D) (III)ANSWER IS B & C29) which of the loop statements always have their body executed at least once? A) The if loop The for loop C) The do-while loopANSWER IS C