Ausnahme Behandlung mit Exceptions Flashcards

1
Q

Wie erfolgt das abfangen von Exceptions?

A

Mit einem catch/true Block. Im Try Block stehen die kritischen Programmanweisungen. Im catch Block werden die Ausnahmen behandelt.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Wofür wird das Schlüsselwort throws genutzt?

A

Damit Methode Exceptions weiterleiten können.
public double preisProArtikel() throws ArithmeticException{
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Wofür wird das Schlüsselwort throw genutzt?

A

Dieses Schlüsselwort ermöglicht das erzeugen einer Exception mit angepasster Fehlermeldung.
catch (ArithmeticException ex) { throw new ArithmeticException(“Warenkorb leer!”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Wie führt man nach den catch Blöcken notwendige aufräumarbeiten durch?

A

Mit dem finally-Block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Wie definiert man eine eigene Exception?

A

public class eigeneausnahme extends Exception

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Was muss beachtet werden wenn man eine eigene Exception programmieren möchte?

A

Sie muss von Oberklasse Exception erben.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Welche Rollen spielen Konstruktoren bei der Erzeugung von Exceptions ?

A

Mithilfe von Konstruktoren kann festgelegt werden, welche Nachricht von der Exception erzeugt wird.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly