Kurs:Informatik I/T5

Aus Wikiversity
Zur Navigation springen Zur Suche springen

T5 - Animation and Exceptions[Bearbeiten]

1 What can be said about the following class definition?

class MyException extends Exception { }


It is an illegal Declaration because it has an empty body.
Its Instances can be caught by "catch (MyException e)".
Its Instances can be caught by "catch (Exception e)".
It is a valid exception definition.

2 A NullPointerException...

...may never be caught, because otherwise the code would be clotted with try-catch and throws clauses.
...may be caught or not, as it is a subtype of RuntimeException.
...must always ba caught.

3 Which Exceptions does the following clause catch?

catch (Exception ex) {...}


Only exceptions of type Exception.
All exceptions of type Exception including Error.
All exceptions of type Exception including RuntimeException.
All types of Exceptions.

4 Any Java program...

... can only start one additional thread.
... ends when all threads are finished.
... ends when the thread running its main method ends.
... can start any number of additional threads.
... must be stopped through external intervention.

5 An AnimatorThread instance...

... has to be started through a method call.
... can Animate exactly one object of type Animate.
... calls when started the Animate object's act() method in an indefinite loop.
... has to contain an act() method.
... is bound to an Animate object through its constructor parameter.
... can Animate any number of objects.
... can Animate any type of object.