Verified | Ace the Test
A loop that searches for a particular value in input is called a(n) : - 🧠
ANSWER ✔✔sentinel loop
final int LASTVAL = -99;
Scanner cin = new Scanner(System.in);
int entry = cin.nextInt();
,while (entry != LASTVAL)
{
int triple = entry * 3;
System.out.println(triple);
entry = cin.nextInt();
}
The above code is an example of a(n) ____ while loop. - 🧠 ANSWER
✔✔sentinel-controlled
Which executes first in a do...while loop? - 🧠 ANSWER ✔✔statement
What is the output of the following Java code?
int num = 0;
while (num < 5)
{
System.out.print(num + " ");
num = num + 1;
}
, System.out.println(); - 🧠 ANSWER ✔✔0 1 2 3 4
Suppose sum and num are int variables, and the input is
18 25 61 6 -1
What is the output of the following code?
Scanner cin = new Scanner(System.in);
sum = 0;
num = cin.nextInt();
while (num != -1)
{
sum = sum + num;
num = cin.nextInt();
}
System.out.println(sum); - 🧠 ANSWER ✔✔110
int x = 5;
int y = 30;
COPYRIGHT©PROFFKERRYMARTIN 2025/2026. YEAR PUBLISHED 2026. COMPANY REGISTRATION NUMBER: 619652435. TERMS OF USE.
PRIVACY STATEMENT. ALL RIGHTS RESERVED