Exam 10: Exceptions
Exam 1: Introduction40 Questions
Exam 2: Data and Expressions40 Questions
Exam 3: Using Classes and Objects40 Questions
Exam 4: Conditionals and Loops40 Questions
Exam 5: Writing Classes40 Questions
Exam 6: Graphical User Interfaces40 Questions
Exam 7: Arrays40 Questions
Exam 8: Inheritance40 Questions
Exam 9: Polymorphism39 Questions
Exam 11: Recursion40 Questions
Exam 10: Exceptions40 Questions
Exam 12: Searching and Sorting40 Questions
Exam 13: Trees40 Questions
Exam 14: Introduction to Collections and Stacks40 Questions
Exam 15: Heaps and Priority Queues40 Questions
Exam 16: Graphs40 Questions
Select questions type
Which of the following methods are part of the Exception class and can be used to give information about a thrown exception?
Free
(Multiple Choice)
4.8/5
(43)
Correct Answer:
C
A(n) _____________________ is an object that defines an unusual or erroneous situation that is typically recoverable.
Free
(Multiple Choice)
4.8/5
(28)
Correct Answer:
B
Consider the following code fragment.
String s;
for(int i = 0; i < s.length(); i++)
System.out.println(s.charAt(i));
What exception will be thrown by this code and why?
Free
(Short Answer)
4.7/5
(35)
Correct Answer:
This code will throw a NullPointerException since the String object s is never instantiated, but it is dereferenced when the charAt method is called.
What is the difference between a checked exception and an unchecked exception?
(Essay)
4.7/5
(30)
Every line of a(n) __________________ is executed no matter what exceptions are thrown.
(Multiple Choice)
4.9/5
(33)
An exception will be propagated until it is caught and handled or until it is passed out of the main method.
(True/False)
4.9/5
(40)
When accessing an element of an array, if the index is outside of the range of the indexes of the array, an exception is thrown.
(True/False)
4.9/5
(37)
Write a short snippet of code that converts the first element of the String[] args array to an integer. It should catch an exception and print out a message if the first element cannot be converted to an integer.
(Essay)
4.9/5
(34)
Consider the following code fragment.
int [] a = new int[50];
a[50] = 100;
Will this code fragment throw an exception? Explain.
(Short Answer)
4.7/5
(35)
Every line in a catch block is guaranteed to be executed in all situations.
(True/False)
4.9/5
(38)
Give two examples of methods in the Exception class that can be used to output information about the Exception.
(Short Answer)
4.9/5
(31)
Write a code fragment that will throw an ArithmeticException. Your code fragment should not use the throw statement.
(Short Answer)
4.9/5
(39)
A(n) ____________________ is used to identify a block of statements that may cause an exception.
(Multiple Choice)
4.9/5
(35)
Which of the following represents the standard input stream?
(Multiple Choice)
4.9/5
(39)
Showing 1 - 20 of 40
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)