10.4 Calling Methods that Throw Exceptions Flashcards

1
Q

📝️ What PITFALLS when code-snnipet doesn’t throw a checked-exception?

A

✅ We can specify it might throws a checked-exception

❌ However, we can NOT wrap it in a try-catch block (Unreachable catch-block)

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

📝️ What are the PITFALLS when Overriding Methods with Exceptions?

A

✅ Having fewer exceptions is ok

❌ Adding new exceptions (✅Unchecked-exceptions is ok (redundant))

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

📝️ What are the three ways of Printing an Exception?

A
  • > System.out.println(exc); //Exception type + message
  • > System.out.println(exc.getMessage()); //message
  • > exc.printStackTrace(); //hierarchy of method calls
How well did you know this?
1
Not at all
2
3
4
5
Perfectly