Exam 12: Exception Handling
Exam 1: Creating Java Programs61 Questions
Exam 2: Using Data67 Questions
Exam 3: Using Methods Classes and Objects66 Questions
Exam 4: More Object Concepts66 Questions
Exam 5: Making Decisions66 Questions
Exam 6: Looping66 Questions
Exam 7: Characters Strings and the Stringbuilder68 Questions
Exam 8: Arrays66 Questions
Exam 9: Advanced Array Concepts66 Questions
Exam 10: Introduction to Inheritance66 Questions
Exam 11: Advanced Inheritance Concepts66 Questions
Exam 12: Exception Handling66 Questions
Exam 13: File Input and Output66 Questions
Exam 14: Introduction to Swing Components66 Questions
Exam 15: Advanced Gui Topics66 Questions
Exam 16: Graphics66 Questions
Select questions type
____ statements are program statements that can never execute under any circumstances.
(Multiple Choice)
4.8/5
(45)
The ____________________ class comprises less serious errors that represent unusual conditions that arise while a program is running and from which the program can recover.
(Short Answer)
4.8/5
(43)
To use a method to its full potential, you must know the method name, return type, type and number of arguments required, and type and number of exceptions the method throws.
(True/False)
4.8/5
(43)
Using the above code, fill in the blank lines to create a catch block that will catch any type of Exception object and display the message "Invalid operation".

(Essay)
4.8/5
(33)
What is unreachable code and how might using multiple catch blocks cause this? Provide an example.
(Essay)
4.8/5
(37)
The figure above represents code that executes in the try block any statements that might throw exceptions, along with a catch and finally block. Explain three different outcomes of the try block that would cause the code in the finally block to execute.

(Essay)
4.7/5
(38)
public static void main(String args[])
{
int a, b;
try
{
a = 0;
b = 42 / a;
System.out.println("This will not be printed.");
}
catch (ArithmeticException e)
{
System.out.println("Division by zero.");
}
System.out.println("After catch statement.");
}
The program above includes a try block and a catch clause that processes the ArithmeticException generated by the division-by-zero error. Explain how the try and catch blocks operate, and what the output will be following program execution.
(Essay)
4.8/5
(40)
The figures above show the HighBalanceException and CustomerAccount classes. Explain what is involved in creating your own throwable Exception s. Explain what will happen if the CustomerAccount throws a HighBalanceException .


(Essay)
4.9/5
(35)
You can place as many statements as you need within a try block, and you can catch as many exceptions as you want.
(True/False)
4.9/5
(32)
When you use a(n) ____ statement, you state a condition that should be true , and Java throws an AssertionError when it is not.
(Multiple Choice)
4.8/5
(45)
public class exceptions
{
public static void main(String Args[])
{
int[] array = new int[3];
try
{
for(int a=0;a
{
array[a] = a;
}
System.out.println(array);
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("Out of bounds");
}
}
}
In the above code, the line System.out.println(array); gets skipped when an exception occurs. Write a finally block that will execute, and will execute a System.out.println(array); if there is an exception.
(Short Answer)
4.9/5
(31)
In the example above, the user might not enter an integer, the conversion to an integer might fail, and an exception might be thrown. Why is this a problem and what are some possible options for fixing these types of errors?


(Essay)
4.8/5
(33)
In the above code, explain the importance of the shaded statement. What occurs if the statement is commented out of the program?

(Essay)
4.9/5
(41)
import java.util.Scanner;
public class AssertTest
{
public static void main( String args[] )
{
Scanner input = new Scanner( System.in );
System.out.print( "Enter a number between 0 and 10: " );
int number = input.nextInt();
assert ( number >= 0 && number
System.out.printf( "You entered %d\n", number );
}
}
The above code demonstrates the functionality of the assert statement. Explain what happens when an entered number is valid and when an entered number is out of range.
(Essay)
4.8/5
(41)
The memory location known as the ____________________ is where the computer stores the list of method locations to which the system must return.
(Short Answer)
4.8/5
(28)
Match each term with the correct statement below.
Correct Answer:
Premises:
Responses:
(Matching)
4.8/5
(38)
A catch block is a method that can be called directly and takes an argument that is some type of exception.
(True/False)
4.8/5
(41)
Showing 21 - 40 of 66
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)