Exam 9: Exception Handling
Exam 1: Getting Started46 Questions
Exam 2: Console Input and Output29 Questions
Exam 3: Flow of Control43 Questions
Exam 4: Defining Classes I44 Questions
Exam 5: Defining Classes Ii46 Questions
Exam 6: Arrays47 Questions
Exam 7: Inheritance43 Questions
Exam 8: Console Input and Output43 Questions
Exam 9: Exception Handling45 Questions
Exam 10: File IO46 Questions
Exam 12: Uml and Patterns22 Questions
Exam 13: Interfaces and Inner Classes32 Questions
Exam 14: Generics and the Arraylist Class31 Questions
Exam 15: Linked Data Structures43 Questions
Exam 16: Collections and Iterators44 Questions
Exam 17: Swing I37 Questions
Exam 18: Swing II31 Questions
Exam 19: Java Never Ends18 Questions
Exam 11: Recursion43 Questions
Exam 20: Applets25 Questions
Select questions type
If you were going to catch an exception of type Exception,where should this catch block be placed within your code?
Free
(Essay)
4.8/5
(40)
Correct Answer:
Catching an exception of type Exception is a very general exception,therefore it should be the last catch block in the series of catches,with the more specific exceptions being caught first.
Define an exception class called NegativeNumberException.The class should have a constructor with no parameters.If an exception is thrown with this zero-argument constructor,getMessage should return "Negative Number Not Allowed!" The class should also have a constructor with a single parameter of type String.If an exception is thrown with this constructor,then getMessage returns the value that was used as an argument to the constructor.
Free
(Essay)
4.7/5
(35)
Correct Answer:
public class NegativeNumberException extends Exception { public NegativeNumberException() { super("Negative Number Detected!"); } public NegativeNumberException(String message) { super(message); } }
When defining your own exception class,you extend an existing exception class.This is an example of:
Free
(Multiple Choice)
4.9/5
(39)
Correct Answer:
C
Exceptions that must follow the Catch or Declare Rule are often called unchecked exceptions.
(True/False)
4.9/5
(43)
When an exception is thrown,the code in the surrounding try block continues executing and then the catch block begins execution.
(True/False)
4.8/5
(35)
The finally block contains code to be executed whether or not an exception is thrown in a try block.
(True/False)
4.8/5
(38)
What is the purpose of the method getMessage()when used with exception handling?
(Essay)
4.9/5
(44)
Methods that process String arguments as if they were numbers could possibly throw a/an _________ exception.
(Multiple Choice)
5.0/5
(32)
Use a catch block to display the exception thrown in number two above.
(Essay)
4.9/5
(36)
Write a Java statement that throws a new exception with the String: Disk drive not ready.
(Essay)
4.9/5
(41)
Use a catch block to display the exception thrown in number one above.
(Essay)
4.8/5
(29)
The basic way of handling exceptions in Java consists of the try-catch-throw trio.
(True/False)
4.9/5
(43)
You can not place a try block and its following catch blocks inside a larger try block or inside a larger catch block.
(True/False)
4.8/5
(34)
Which circumstance is an exception to the catch or declare rule?
(Multiple Choice)
4.9/5
(32)
Showing 1 - 20 of 45
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)