Java Reference
In-Depth Information
Review Questions
1.
What are the two types of exceptions in Java? How are they distinguished?
2.
If an object is to be thrown using the throw keyword, the object must be what
data type?
3.
True or False: A try block must be followed by exactly one corresponding catch block.
4.
What is the term used to refer to code within a try block?
5.
True or False: A finally block always executes, whether or not an exception occurs in
the corresponding try block.
6.
The following try/catch block does not compile. Why not?
try
{
}catch(Exception e)
{
}catch(RuntimeException r)
{
}
7.
Suppose that a RemoteException occurs in the following try block. What will be
displayed next?
try
{
//A RemoteException occurs here
}catch(RemoteException r)
{
System.out.println(“Something went wrong.”);
throw r;
}finally
{
System.out.println(“Finally!”);
}
8.
What is the output of the try/catch block in the previous question if no Remote-
Exception occurs?
9.
What is the output of the same try/catch block if a NullPointerException occurs in the
protected code (instead of a RemoteException)?
10.
The Handle or Declare Rule applies only to what type of exception?
11.
What keyword is used by a method to declare an exception?
12.
What keyword is used by a method to throw an exception?
Search WWH ::




Custom Search