10.1 Understanding Exceptions Flashcards

1
Q

📝️ What is a Java Exception?

A

An exception is an event that disrupts/alter the normal flow of an application

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

📝️ What is the java.lang.Throwable class?

A

It’s the Java superclass for all objects that represent an Exception event.

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

📝️ What are the key subclasses of Throwable

(Exception-types)?

A
  • > Error
  • > RuntimeExceptions [Unchecked]
  • > Exceptions [Checked Exceptions]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

📝️What does the 💥️Error💥️ class represents (examples)?

A
  • > An Error means something went so horribly wrong that your program should not attempt to recover from it.
    e. g: The disk drive “disappeared” or the program ran out of memory.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

📝️ What does 💥️Checked Exception💥️ mean in Java?

A
  • > Checked exceptions include any class that inherits Throwable, but does NOT inherit from Error nor RuntimeException classes.
  • > It’s an exception that needs to be anticipated in other words, it must be caught or declared.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

📝️ What is an 💥️Unchecked Exception💥️ class?

A

o An Unchecked exception is a RuntimeException or any of its subclasses.
o It does NOT have to be handled nor declared.
o This kind of exceptions can be thrown by the JVM itself or the programmer code.

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

What Exception classes…

are Catcheable or Have to be Declared (Table)?

A

👉️ Error |✅|✅| ⚠️ You shouldn’t but you can
👉️ Unchecked Exc. |✅|✅| ❓️ You can but you don’t have to
👉️ Checked Excep |✅|✅| 💪️You have to

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

📝️ What does the 💥️HANDLE OR DECLARE💥️ rule means?

A

It means that Checked Exceptions should be handle or declared
👉️ handle -> 🕵‍♂️️’throw’ Wrapped in compatible try and catch blocks
👉️ declared -> 🕵‍♂️️’throws’ Defined that this method ‘throws’ a certain exception in the method signature …(someone else will handle it.)

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

📝️ What are the keywords used to declare and delegate exception handling (when)?

A
  • > throw - When a particular condition is matched we can throw an Exception …e.g: throw new IOException();
  • > throws - It is used at the end of a method declaration …e.g: throws IOException
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

📝️ What is the ‘throw’ keyword used for?

A

o It’s used to declare a new exception (throw) or re-throw an existing one.
-> It goes as an statement inside a code block.

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

📝️ What does throws statement mean in java?

A

-> The throws keyword indicates that a certain method can potentially “throw” an specific exception.

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