Examlex

Solved

Assertions
for the Following Method, Identify Each of the Three

question 8

Essay

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. (can abbreviate as A/N/S)
public static int threeHeads() { // Counts coin tosses till we get heads 3x in a row.
Random rand = new Random();
int flip = 1;
int heads = 0;
int count = 0;
// Point A
while (heads < 3) {
// Point B
flip = rand.nextInt(2); // flip coin
if (flip == 0) { // heads
heads++;
// Point C
} else { // tails
// Point D
heads = 0;
}
count++;
}
// Point E
return count;
}
flip==0 heads ==0 flip > heads  Point A  Point B  Point C  Point D  Point E \begin{array}{|l|l|l|l|}\hline & f l i p==0 & \text { heads }==0 & \text { flip }>\text { heads } \\\hline \text { Point A } & & & \\\hline \text { Point B } & & & \\\hline \text { Point C } & & & \\\hline \text { Point D } & & & \\\hline \text { Point E } & & & \\\hline\end{array}


Definitions:

Materials Price Variance

The difference between the actual cost of materials and the standard (or expected) cost, indicating how much more or less was spent on materials than was planned.

Labor Rate Variance

The difference between the actual cost of labor and the budgeted cost of labor at the standard rate.

Variable Overhead Rate Variance

The difference between the actual variable overhead incurred and the expected variable overhead based on standard cost accounting.

Variable Overhead Rate Variance

The difference between the actual variable overhead incurred and the expected variable overhead based on the predetermined rate.

Related Questions