A parcel service calculates the average number of labels per parcel when distributing 10 labels. A tester evaluates each Java method independently for every row below. A failure in one test does not prevent any other test from running.
static double averageA(int parcels) { return 10 / parcels; } static double averageB(int parcels) { return (double) (10 / parcels); } static double averageC(int parcels) { return (double) 10 / parcels; }
The (double) syntax is a cast. For nonzero parcel counts, compare returned values with the exact mathematical average of 10 divided by the parcel count. Ignore ordinary floating-point rounding.
Test run
Parcels
Cedar
0
Maple
2
Pine
3
Birch
4
Alder
Spruce
5
Willow
6
Fir
8
Report these four quantities as exact whole numbers of runs:
Unlock full course notes by signing up
Tracing output up to an off-by-one exception
The following Java statements run inside main with no exception handling. The program prints some numbers and then stops with a runtime exception.
What is the last number printed before the program stops? Give your answer as a whole number.
Classifying throwable types by inheritance
A developer is documenting three Java failure classes, using one supporting relationship as context. The relevant inheritance relationships are given below; extends names a class's immediate parent.
Complete the report. Use checked or unchecked for the first two blanks and the appropriate parent class name for the last blank.
Exception category of IOException: ________