The following Java statements run inside main with no exception handling. The program prints some numbers and then stops with a runtime exception.
int[] data = {4, 7, 2, 9}; int total = 0; for (int i = 0; i <= data.length; i++) { total += data[i]; System.out.println(total); } System.out.println("Done");
What is the last number printed before the program stops? Give your answer as a whole number.
Unlock full course notes by signing up
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: ________
Exceptions and silent errors in parcel averages
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.
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.
Report these four quantities as exact whole numbers of runs: