Exeptions Flashcards

(26 cards)

1
Q

Was ist eine Exception?

A

Ein Event der bei Ausführung des Programms auftaucht.

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

Was passiert, wenn ein Error geschieht?

A

Throwing an Exception

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

Was passiert bei “Throwing an Exception?

A

a) Exception Objekt Schaffung

b) Übergabe an Runtime System

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

Was ist im Exception Objekt drinnen?

A

Spezifische info über Error:
Typ
State des Programms zum Zeitpunkt des Auftauchens

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

Welche Challenges muss mach bewältigen, bei Exception-Handling

A

Wie handeln wir?

Wo machen wir dies? Main oder Methode selbst

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

Was ist Call Stack

A

Bei Exception wird das Object hierarchisch von Methode zu Methode weitergegeben ?

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

Was ist besser?

Handling oder Carefull Programming?

A

Carefull Programming

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

Welche Optionen habe ich bei der es zu Exeptions kommen kann.

A

o1) locally mit try/catch block

o2) pass it on to the call stack hierarchie, and handle it elsewhere.

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

Wo sollte Handling am Besten geschehen?

A

lokal

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

Wann ist es gut die Exception weiterzugeben?

A

Wenn die Exeption oder eben ihre Informationen weiter oberhalb im Call Stack verwendet werden -Kontext Informationen

Oder mehrere Methoden machen gleiche Exception, dann ist Option2 eine Art Trichter/Sammler

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

was gehort in try{..}?

A

der Teil der eine Exception werfen kann.

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

was gehört im catch {…}-block?

A

Code für://Do somethnig usefull if Exception occur!

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

Wie kann ich statt mehrere catch-Blöcke nur mit einem Catch-Block mehrere Exceptions handeln?

A

catch (Exeption1|Exception2 ex){}

siehe pipe bei auflistung und ex für das object

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

Für welchen spezifischen User-Fall mache ich try/catch

A

unsinniger UserInput, string statt int eingegeben

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

was ist der Unterschied zwischen Checked und Unchecked?

A

Checked:
damit kann ich umgehen. Umfasst alles Vermeidbare., damit das Programm in Runtime damit umgehen kann.

Unchecked:
Nicht vermeidbar, mit Input Validation.
Umfast alles was in Runtime nicht zu vermeiden mit input validation.
“Programmer should have checked this!”

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

Was kann ich machen bei Checked Exceptions?

A

Exception-Klasse erweiter
Compiler weisst schon darauf hin, diesen beachten.
Input/Output-Handling umsetzen, da häufigste Checked sind durch UserInput.

17
Q

Was mache ich bei Unchecked Exceptions?

A
ArtithmeticException
NullPonterException
IllegalArgumentException
IllegalStateException
IndexOutOfBoundsExceptions
18
Q

Was ist die finally-Clause?

A

mit ihr kann ich sicherstellen, dass etwas immer durchgeführt werden soll. zb. scanner.clos()

19
Q

wann kommt die finnalyClause zum Zuge

A

immer, egal ob mit Exception oder nicht.

20
Q

Was ist kann ich machen um Userinput zu prüfen?

A

User Input Validation

21
Q

Gehort Falscher user Input zu den erwarteten Errors

22
Q

Beispiele für Input Validation

A

range prüfen
Input Typ

NumberFormatException e
InputMismatfchExcetopn e

23
Q

Self Made Exception Types, sind eigene Klassen oder Subklassen?

24
Q

Welche Klassen erweitere ich mit Self Made Exc?

A

Exception: checked
RuntimeExceptions: unchecked

25
Was muss mindestens mache wenn ich eine Self Made exception mache?
Constructor, mind einer. | Gut wäre auch Storen von mehr information über Exception
26
Was ist das Ziel von Exception Handling?
Programm soll weiterlaufen.