Question: Question 111 pts A try statement can have more than one catch statement. True False Flag this Question Question 121 pts Unchecked exceptions must be
Question 111 pts
A try statement can have more than one catch statement.
| True |
| False |
Flag this Question
Question 121 pts
Unchecked exceptions must be caught or listed in the throws clause of a method.
| True |
| False |
Flag this Question
Question 131 pts
Checked exceptions must be caught or listed in the throws clause of a method.
| True |
| False |
Flag this Question
Question 141 pts
Any kind of exception (checked or unchecked) can be listed in the throws clause of a method.
| True |
| False |
Flag this Question
Question 151 pts
Any kind of exception (checked or unchecked) can be caught in a method.
| True |
| False |
Flag this Question
Question 162 pts
Which is true about the following method?
public void doSomething(int n) { if(n<0) throw new Exception("Negative Number"); } | it will not compile, but it could be fixed by adding a try/catch block |
| it will not compile, but it could be fixed by adding a throws clause to the method header |
| it will compile and run without crashing |
| it will compile and run but then crash |
Flag this Question
Question 173 pts
The code in a finally clause will execute under which conditions? Select all that apply.
| the try block that precedes it throws an exception that is caught |
| the try block that precedes it does not throw an exception |
| the try block that precedes it throws an exception that is not caught |
Flag this Question
Question 183 pts
Consider the following code fragments:
public void methodA() { ... methodB(); } public void methodB() { ... methodC(); } public void methodC() { ... // an unchecked exception is thrown } In order for the code to compile, where could the unchecked exception be caught and handled? Select all that apply.
| methodC |
| whatever method invokes methodA |
| methodB |
| methodA |
Flag this Question
Question 191 pts
Which of the following methods invoked on a String object str might throw a StringIndexOutOfBoundsException?
| str.length() |
| str.equals(str) |
| str.charAt(2) |
| str.replace('a', 'A') |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
