Complete the code to identify the type of runtime error.
try { int result = 10 / [1]; } catch (ArithmeticException e) { System.out.println("Runtime error: Division by zero"); }
The runtime error occurs when dividing by zero, so the blank should be filled with 0.
Complete the code to catch a null pointer exception at runtime.
String text = null; try { int length = text.[1](); } catch (NullPointerException e) { System.out.println("Runtime error: Null pointer"); }
The method to get the length of a string is length(). Calling it on a null object causes a NullPointerException at runtime.
Fix the error in the code to properly handle an array index out of bounds exception.
int[] numbers = {1, 2, 3};
try {
int value = numbers[[1]];
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Runtime error: Index out of bounds");
}Accessing index 3 in an array of size 3 causes an ArrayIndexOutOfBoundsException at runtime. The blank should be filled with 3 to trigger the error.
Fill both blanks to create a dictionary comprehension that filters runtime errors by severity.
errors = {code: desc for code, desc in error_list if code [1] 400 and code [2] 500}The comprehension filters codes greater than or equal to 400 and less than 500 to select runtime errors in that range.
Fill all three blanks to create a dictionary comprehension that maps error codes to descriptions for runtime errors only.
runtime_errors = { [1]: [2] for [3] in errors.items() if 400 <= [1] < 500}The comprehension uses code as key, desc as value, and code, desc as the loop variable to filter runtime errors with codes between 400 and 499.