1. Suppose that you have to interface your code with some Java classes
a co-worker has created. As part of the
classes, your co-worker has created the TypeAException class that extends
Exception and two sub-classes. This
hierarchy is summarized as follows:
Java.lang.Exception
|
+-TypeAException
|
+-TypeA1Exception
+-TypeA2Exception
In the CalcTypeA class, the method calcStuff is declared:
public double calcStuff() throws TypeA1Exception
Will the compiler insist that a method calling calcStuff provide
for catching or rethrowing a
TypeA1Exception?
a) Yes, the compiler
will require provision for the exception
b) No, the compiler
will not require provision for the exception
2. Referring to the exception hierarchy in question 1, you are creating
a method that may throw a
TypeA1Exception or a TypeA2Exception. Which of the following
declerations would be acceptable to the Java
compiler? Choose all acceptable declerations.
a) float methodA()
throws TypeA2Exception
b) float methodA()
throws TypeAException
c) float methodA()
throws TypeA1Exception, TypeA2Exception
d) float methodA()
throws Exception
3. Assuming that the TypeAException class mentioned in question 1 has
a no-argument constructor, which of the
following is a valid complete statement to throw a TypeAException.
a) throw new TypeAException();
b) new TypeAException();
c) throw TypeAException();
d) throws new TypeAException();