Skip to content

Commit b1ddf8a

Browse files
committed
Update about and exercise introduction to match concept changes
1 parent 5346c08 commit b1ddf8a

File tree

2 files changed

+30
-24
lines changed

2 files changed

+30
-24
lines changed

concepts/exceptions/about.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ An exception is an event that occurs during the execution of a program that disr
88
Exceptions are raised explicitly in Java, and the act of raising an exception is called _throwing an exception_.
99
The act of handling an exception is called _catching an exception_.
1010

11+
In Java, all exceptions are subclasses of the `Exception` class, which itself is a subclass of `Throwable`.
12+
1113
Java distinguishes two types of exceptions:
1214

1315
1. Checked exceptions
@@ -20,7 +22,7 @@ An example of a checked exception is the `FileNotFoundException` which occurs wh
2022

2123
This type of exception is checked at compile-time: methods that throw checked exceptions should specify this in their method signature, and code calling a method that might throw a checked exception is required to handle it or the code will not compile.
2224

23-
All exceptions in Java that do not inherit from `RuntimeException` are checked exceptions.
25+
All checked exceptions are subclasses of `Exception` that do not extend `RuntimeException`.
2426

2527
### Unchecked exceptions
2628

@@ -29,17 +31,7 @@ An example of an unchecked exception is the `NullPointerException` which occurs
2931

3032
This type of exception is not checked at compile-time: methods that throw unchecked exceptions are not required to specify this in their method signature, and code calling a method that might throw an unchecked exception is not required to handle it.
3133

32-
All exceptions in Java that inherit from `RuntimeException` are unchecked exceptions.
33-
34-
## Errors
35-
36-
Java also has a separate category called _Errors_ which are serious problems that are external to an application.
37-
An example of an error is the `OutOfMemoryError` which occurs when an application is trying to use more memory than is available on the system.
38-
39-
Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code.
40-
Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle.
41-
42-
All errors in Java inherit from the `Error` class.
34+
All unchecked exceptions inherit from `RuntimeException`, which itself is an extension of `Exception`.
4335

4436
## Throwing exceptions
4537

@@ -134,6 +126,17 @@ Withdrawal failed: Cannot withdraw a negative amount
134126
Current balance: 5.0
135127
```
136128

129+
## Errors
130+
131+
Java also has a separate category called _Errors_ which are serious problems that are external to an application.
132+
An example of an error is the `OutOfMemoryError` which occurs when an application is trying to use more memory than is available on the system.
133+
134+
Like unchecked exceptions, errors are not checked at compile-time.
135+
The difference is that they represent system level problems and are generally thrown by the Java Virtual machine or environment instead of the application.
136+
Applications should generally not attempt to catch or handle them.
137+
138+
All errors in Java inherit from the `Error` class.
139+
137140
## When not to use exceptions
138141

139142
As stated previously, exceptions are events that disrupt the normal flow of instructions, and are used to handle _exceptional events_.

exercises/concept/calculator-conundrum/.docs/introduction.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ An exception is an event that occurs during the execution of a program that disr
1010
Exceptions are raised explicitly in Java, and the act of raising an exception is called _throwing an exception_.
1111
The act of handling an exception is called _catching an exception_.
1212

13+
In Java, all exceptions are subclasses of the `Exception` class, which itself is a subclass of `Throwable`.
14+
1315
Java distinguishes two types of exceptions:
1416

1517
1. Checked exceptions
@@ -22,7 +24,7 @@ An example of a checked exception is the `FileNotFoundException` which occurs wh
2224

2325
This type of exception is checked at compile-time: methods that throw checked exceptions should specify this in their method signature, and code calling a method that might throw a checked exception is required to handle it or the code will not compile.
2426

25-
All exceptions in Java that do not inherit from `RuntimeException` are checked exceptions.
27+
All checked exceptions are subclasses of `Exception` that do not extend `RuntimeException`.
2628

2729
#### Unchecked exceptions
2830

@@ -31,17 +33,7 @@ An example of an unchecked exception is the `NullPointerException` which occurs
3133

3234
This type of exception is not checked at compile-time: methods that throw unchecked exceptions are not required to specify this in their method signature, and code calling a method that might throw an unchecked exception is not required to handle it.
3335

34-
All exceptions in Java that inherit from `RuntimeException` are unchecked exceptions.
35-
36-
### Errors
37-
38-
Java also has a separate category called _Errors_ which are serious problems that are external to an application.
39-
An example of an error is the `OutOfMemoryError` which occurs when an application is trying to use more memory than is available on the system.
40-
41-
Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code.
42-
Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle.
43-
44-
All errors in Java inherit from the `Error` class.
36+
All unchecked exceptions inherit from `RuntimeException`, which itself is an extension of `Exception`.
4537

4638
### Throwing exceptions
4739

@@ -135,3 +127,14 @@ Withdrawing -10.0
135127
Withdrawal failed: Cannot withdraw a negative amount
136128
Current balance: 5.0
137129
```
130+
131+
### Errors
132+
133+
Java also has a separate category called _Errors_ which are serious problems that are external to an application.
134+
An example of an error is the `OutOfMemoryError` which occurs when an application is trying to use more memory than is available on the system.
135+
136+
Like unchecked exceptions, errors are not checked at compile-time.
137+
The difference is that they represent system level problems and are generally thrown by the Java Virtual machine or environment instead of the application.
138+
Applications should generally not attempt to catch or handle them.
139+
140+
All errors in Java inherit from the `Error` class.

0 commit comments

Comments
 (0)