Assertions
For the following method, identify each of the three assertions in the table below as being either ALWAYS true, NEVER true or SOMETIMES true / sometimes false at each labeled point in the code. You may abbreviate these choices as A/N/S respectively.
public static int mystery(Scanner console) {
int y = 0;
int z = 1;
int next = console.nextInt();
// Point A
while (next >= 0) {
// Point B
if (y > z) {
// Point C
z = y;
}
y++;
next = console.nextInt();
// Point D
}
// Point E
return z;
}
Correct Answer:
Verified
Q1: Programming
Write a static method named printMultiples that
Q2: If/Else Simulation
For each call of the method
Q3: Parameter Mystery
At the bottom of the page,
Q4: Programming
Write a static method named threeHeads that
Q5: Programming
Write a static method named monthApart that
Q6: While Loop Simulation
For each call of the
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents