From 746fae76606638867a4d146769bfe878afc5dc76 Mon Sep 17 00:00:00 2001 From: BahaaMohamed98 Date: Thu, 12 Jun 2025 00:35:59 +0300 Subject: [PATCH 1/7] Update exception terminology to clarify types of exceptions --- concepts/exceptions/about.md | 17 +++++++---------- concepts/exceptions/introduction.md | 17 +++++++---------- .../calculator-conundrum/.docs/introduction.md | 17 +++++++---------- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/concepts/exceptions/about.md b/concepts/exceptions/about.md index 96e2bc4a5..7e5a385a1 100644 --- a/concepts/exceptions/about.md +++ b/concepts/exceptions/about.md @@ -8,11 +8,10 @@ An exception is an event that occurs during the execution of a program that disr Exceptions are raised explicitly in Java, and the act of raising an exception is called _throwing an exception_. The act of handling an exception is called _catching an exception_. -Java distinguishes three types of exceptions: +Java distinguishes two types of exceptions: 1. Checked exceptions 2. Unchecked exceptions -3. Errors ### Checked exceptions @@ -21,7 +20,7 @@ An example of a checked exception is the `FileNotFoundException` which occurs wh 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. -All exceptions in Java that do not inherit from `RuntimeException` or `Error` are considered checked exceptions. +All exceptions in Java that do not inherit from `RuntimeException` are checked exceptions. ### Unchecked exceptions @@ -30,17 +29,15 @@ An example of an unchecked exception is the `NullPointerException` which occurs 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. -All exceptions in Java that inherit from `RuntimeException` are considered unchecked exceptions. +All exceptions in Java that inherit from `RuntimeException` are unchecked exceptions. -### Errors +## Errors -_Errors_ are exceptional conditions that are external to an application. -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. +Java also has a separate category called _Errors_ which are serious problems that are external to an application. 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. -Like unchecked exceptions, errors are not checked at compile-time. -They are not usually thrown from application code. +Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code. Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle. -All exceptions in Java that inherit from `Error` are considered errors. +All errors in Java inherit from the `Error` class. ## Throwing exceptions diff --git a/concepts/exceptions/introduction.md b/concepts/exceptions/introduction.md index 586f6f1ea..412648141 100644 --- a/concepts/exceptions/introduction.md +++ b/concepts/exceptions/introduction.md @@ -8,11 +8,10 @@ An exception is an event that occurs during the execution of a program that disr Exceptions are raised explicitly in Java, and the act of raising an exception is called _throwing an exception_. The act of handling an exception is called _catching an exception_. -Java distinguishes three types of exceptions: +Java distinguishes two types of exceptions: 1. Checked exceptions 2. Unchecked exceptions -3. Errors ### Checked exceptions @@ -21,7 +20,7 @@ An example of a checked exception is the `FileNotFoundException` which occurs wh 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. -All exceptions in Java that do not inherit from `RuntimeException` or `Error` are considered checked exceptions. +All exceptions in Java that do not inherit from `RuntimeException` are checked exceptions. ### Unchecked exceptions @@ -30,17 +29,15 @@ An example of an unchecked exception is the `NullPointerException` which occurs 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. -All exceptions in Java that inherit from `RuntimeException` are considered unchecked exceptions. +All exceptions in Java that inherit from `RuntimeException` are unchecked exceptions. -### Errors +## Errors -_Errors_ are exceptional conditions that are external to an application. -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. +Java also has a separate category called _Errors_ which are serious problems that are external to an application. 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. -Like unchecked exceptions, errors are not checked at compile-time. -They are not usually thrown from application code. +Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code. Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle. -All exceptions in Java that inherit from `Error` are considered errors. +All errors in Java inherit from the `Error` class. ## Throwing exceptions diff --git a/exercises/concept/calculator-conundrum/.docs/introduction.md b/exercises/concept/calculator-conundrum/.docs/introduction.md index e9b19e65f..c79e6adc9 100644 --- a/exercises/concept/calculator-conundrum/.docs/introduction.md +++ b/exercises/concept/calculator-conundrum/.docs/introduction.md @@ -10,11 +10,10 @@ An exception is an event that occurs during the execution of a program that disr Exceptions are raised explicitly in Java, and the act of raising an exception is called _throwing an exception_. The act of handling an exception is called _catching an exception_. -Java distinguishes three types of exceptions: +Java distinguishes two types of exceptions: 1. Checked exceptions 2. Unchecked exceptions -3. Errors #### Checked exceptions @@ -23,7 +22,7 @@ An example of a checked exception is the `FileNotFoundException` which occurs wh 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. -All exceptions in Java that do not inherit from `RuntimeException` or `Error` are considered checked exceptions. +All exceptions in Java that do not inherit from `RuntimeException` are checked exceptions. #### Unchecked exceptions @@ -32,17 +31,15 @@ An example of an unchecked exception is the `NullPointerException` which occurs 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. -All exceptions in Java that inherit from `RuntimeException` are considered unchecked exceptions. +All exceptions in Java that inherit from `RuntimeException` are unchecked exceptions. -#### Errors +### Errors -_Errors_ are exceptional conditions that are external to an application. -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. +Java also has a separate category called _Errors_ which are serious problems that are external to an application. 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. -Like unchecked exceptions, errors are not checked at compile-time. -They are not usually thrown from application code. +Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code. Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle. -All exceptions in Java that inherit from `Error` are considered errors. +All errors in Java inherit from the `Error` class. ### Throwing exceptions From 498b1e4ef202d0c44f5e4687d2c39162985c8dc4 Mon Sep 17 00:00:00 2001 From: BahaaMohamed98 Date: Thu, 12 Jun 2025 02:06:07 +0300 Subject: [PATCH 2/7] Split explanation of Errors into separate lines --- concepts/exceptions/about.md | 6 ++++-- concepts/exceptions/introduction.md | 6 ++++-- .../concept/calculator-conundrum/.docs/introduction.md | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/concepts/exceptions/about.md b/concepts/exceptions/about.md index 7e5a385a1..89abcb5c9 100644 --- a/concepts/exceptions/about.md +++ b/concepts/exceptions/about.md @@ -33,9 +33,11 @@ All exceptions in Java that inherit from `RuntimeException` are unchecked except ## Errors -Java also has a separate category called _Errors_ which are serious problems that are external to an application. 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. +Java also has a separate category called _Errors_ which are serious problems that are external to an application. +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. -Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code. Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle. +Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code. +Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle. All errors in Java inherit from the `Error` class. diff --git a/concepts/exceptions/introduction.md b/concepts/exceptions/introduction.md index 412648141..7fc7e5520 100644 --- a/concepts/exceptions/introduction.md +++ b/concepts/exceptions/introduction.md @@ -33,9 +33,11 @@ All exceptions in Java that inherit from `RuntimeException` are unchecked except ## Errors -Java also has a separate category called _Errors_ which are serious problems that are external to an application. 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. +Java also has a separate category called _Errors_ which are serious problems that are external to an application. +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. -Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code. Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle. +Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code. +Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle. All errors in Java inherit from the `Error` class. diff --git a/exercises/concept/calculator-conundrum/.docs/introduction.md b/exercises/concept/calculator-conundrum/.docs/introduction.md index c79e6adc9..65acb36f7 100644 --- a/exercises/concept/calculator-conundrum/.docs/introduction.md +++ b/exercises/concept/calculator-conundrum/.docs/introduction.md @@ -35,9 +35,11 @@ All exceptions in Java that inherit from `RuntimeException` are unchecked except ### Errors -Java also has a separate category called _Errors_ which are serious problems that are external to an application. 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. +Java also has a separate category called _Errors_ which are serious problems that are external to an application. +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. -Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code. Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle. +Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code. +Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle. All errors in Java inherit from the `Error` class. From 88297ef62dcef83ffeb122cfaed9afc1d693bf7f Mon Sep 17 00:00:00 2001 From: BahaaMohamed98 Date: Sun, 15 Jun 2025 13:09:09 +0300 Subject: [PATCH 3/7] Clarify exception hierarchy and definitions in introduction --- concepts/exceptions/introduction.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/concepts/exceptions/introduction.md b/concepts/exceptions/introduction.md index 7fc7e5520..07dc1f002 100644 --- a/concepts/exceptions/introduction.md +++ b/concepts/exceptions/introduction.md @@ -8,6 +8,8 @@ An exception is an event that occurs during the execution of a program that disr Exceptions are raised explicitly in Java, and the act of raising an exception is called _throwing an exception_. The act of handling an exception is called _catching an exception_. +In Java, all exceptions are subclasses of the `Exception` class, which itself is a subclass of `Throwable`. + Java distinguishes two types of exceptions: 1. Checked exceptions @@ -20,7 +22,7 @@ An example of a checked exception is the `FileNotFoundException` which occurs wh 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. -All exceptions in Java that do not inherit from `RuntimeException` are checked exceptions. +All checked exceptions are subclasses of `Exception` that do not extend `RuntimeException`. ### Unchecked exceptions @@ -29,7 +31,7 @@ An example of an unchecked exception is the `NullPointerException` which occurs 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. -All exceptions in Java that inherit from `RuntimeException` are unchecked exceptions. +All unchecked exceptions inherit from `RuntimeException`, which itself is an extension of `Exception`. ## Errors From f27f57cfe6cbe3ebdfb48811af86807e57d62173 Mon Sep 17 00:00:00 2001 From: BahaaMohamed98 Date: Sun, 15 Jun 2025 13:15:23 +0300 Subject: [PATCH 4/7] Move Errors section to the end of the introduction --- concepts/exceptions/introduction.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/concepts/exceptions/introduction.md b/concepts/exceptions/introduction.md index 07dc1f002..6b1dc73ad 100644 --- a/concepts/exceptions/introduction.md +++ b/concepts/exceptions/introduction.md @@ -33,16 +33,6 @@ This type of exception is not checked at compile-time: methods that throw unchec All unchecked exceptions inherit from `RuntimeException`, which itself is an extension of `Exception`. -## Errors - -Java also has a separate category called _Errors_ which are serious problems that are external to an application. -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. - -Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code. -Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle. - -All errors in Java inherit from the `Error` class. - ## Throwing exceptions A method in Java can throw an exception by using the `throw` statement. @@ -135,3 +125,13 @@ Withdrawing -10.0 Withdrawal failed: Cannot withdraw a negative amount Current balance: 5.0 ``` + +## Errors + +Java also has a separate category called _Errors_ which are serious problems that are external to an application. +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. + +Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code. +Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle. + +All errors in Java inherit from the `Error` class. From debab47b6e2dd7c4b6a200a9eaad927be154bd7c Mon Sep 17 00:00:00 2001 From: BahaaMohamed98 Date: Sun, 15 Jun 2025 13:26:17 +0300 Subject: [PATCH 5/7] Clarify error vs unchecked exception --- concepts/exceptions/introduction.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/concepts/exceptions/introduction.md b/concepts/exceptions/introduction.md index 6b1dc73ad..c50113113 100644 --- a/concepts/exceptions/introduction.md +++ b/concepts/exceptions/introduction.md @@ -131,7 +131,8 @@ Current balance: 5.0 Java also has a separate category called _Errors_ which are serious problems that are external to an application. 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. -Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code. -Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle. +Like unchecked exceptions, errors are not checked at compile-time. +The difference is that they represent system level problems and are generally thrown by the Java Virtual machine or environment instead of the application. +Applications should generally not attempt to catch or handle them. All errors in Java inherit from the `Error` class. From 5346c082907b7166d6aeaa0f7d5497dcffe4084a Mon Sep 17 00:00:00 2001 From: BahaaMohamed98 Date: Sun, 15 Jun 2025 18:21:25 +0300 Subject: [PATCH 6/7] Add BahaaMohamed98 as a contributor --- concepts/exceptions/.meta/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/concepts/exceptions/.meta/config.json b/concepts/exceptions/.meta/config.json index 1c6bc8bb3..ef26a0098 100644 --- a/concepts/exceptions/.meta/config.json +++ b/concepts/exceptions/.meta/config.json @@ -1,5 +1,5 @@ { "blurb": "Exceptions are thrown when an error that needs special handling occurs.", "authors": ["sanderploegsma"], - "contributors": [] + "contributors": ["BahaaMohamed98"] } From b1ddf8a8f61306262d8c03a0492e2866b1481455 Mon Sep 17 00:00:00 2001 From: BahaaMohamed98 Date: Mon, 16 Jun 2025 16:11:05 +0300 Subject: [PATCH 7/7] Update about and exercise introduction to match concept changes --- concepts/exceptions/about.md | 27 ++++++++++--------- .../.docs/introduction.md | 27 ++++++++++--------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/concepts/exceptions/about.md b/concepts/exceptions/about.md index 89abcb5c9..d3a4f5946 100644 --- a/concepts/exceptions/about.md +++ b/concepts/exceptions/about.md @@ -8,6 +8,8 @@ An exception is an event that occurs during the execution of a program that disr Exceptions are raised explicitly in Java, and the act of raising an exception is called _throwing an exception_. The act of handling an exception is called _catching an exception_. +In Java, all exceptions are subclasses of the `Exception` class, which itself is a subclass of `Throwable`. + Java distinguishes two types of exceptions: 1. Checked exceptions @@ -20,7 +22,7 @@ An example of a checked exception is the `FileNotFoundException` which occurs wh 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. -All exceptions in Java that do not inherit from `RuntimeException` are checked exceptions. +All checked exceptions are subclasses of `Exception` that do not extend `RuntimeException`. ### Unchecked exceptions @@ -29,17 +31,7 @@ An example of an unchecked exception is the `NullPointerException` which occurs 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. -All exceptions in Java that inherit from `RuntimeException` are unchecked exceptions. - -## Errors - -Java also has a separate category called _Errors_ which are serious problems that are external to an application. -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. - -Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code. -Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle. - -All errors in Java inherit from the `Error` class. +All unchecked exceptions inherit from `RuntimeException`, which itself is an extension of `Exception`. ## Throwing exceptions @@ -134,6 +126,17 @@ Withdrawal failed: Cannot withdraw a negative amount Current balance: 5.0 ``` +## Errors + +Java also has a separate category called _Errors_ which are serious problems that are external to an application. +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. + +Like unchecked exceptions, errors are not checked at compile-time. +The difference is that they represent system level problems and are generally thrown by the Java Virtual machine or environment instead of the application. +Applications should generally not attempt to catch or handle them. + +All errors in Java inherit from the `Error` class. + ## When not to use exceptions As stated previously, exceptions are events that disrupt the normal flow of instructions, and are used to handle _exceptional events_. diff --git a/exercises/concept/calculator-conundrum/.docs/introduction.md b/exercises/concept/calculator-conundrum/.docs/introduction.md index 65acb36f7..49103a297 100644 --- a/exercises/concept/calculator-conundrum/.docs/introduction.md +++ b/exercises/concept/calculator-conundrum/.docs/introduction.md @@ -10,6 +10,8 @@ An exception is an event that occurs during the execution of a program that disr Exceptions are raised explicitly in Java, and the act of raising an exception is called _throwing an exception_. The act of handling an exception is called _catching an exception_. +In Java, all exceptions are subclasses of the `Exception` class, which itself is a subclass of `Throwable`. + Java distinguishes two types of exceptions: 1. Checked exceptions @@ -22,7 +24,7 @@ An example of a checked exception is the `FileNotFoundException` which occurs wh 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. -All exceptions in Java that do not inherit from `RuntimeException` are checked exceptions. +All checked exceptions are subclasses of `Exception` that do not extend `RuntimeException`. #### Unchecked exceptions @@ -31,17 +33,7 @@ An example of an unchecked exception is the `NullPointerException` which occurs 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. -All exceptions in Java that inherit from `RuntimeException` are unchecked exceptions. - -### Errors - -Java also has a separate category called _Errors_ which are serious problems that are external to an application. -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. - -Like unchecked exceptions, errors are not checked at compile-time and are not usually thrown from application code. -Unlike exceptions, Errors represent serious system-level problems that applications should generally not attempt to catch or handle. - -All errors in Java inherit from the `Error` class. +All unchecked exceptions inherit from `RuntimeException`, which itself is an extension of `Exception`. ### Throwing exceptions @@ -135,3 +127,14 @@ Withdrawing -10.0 Withdrawal failed: Cannot withdraw a negative amount Current balance: 5.0 ``` + +### Errors + +Java also has a separate category called _Errors_ which are serious problems that are external to an application. +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. + +Like unchecked exceptions, errors are not checked at compile-time. +The difference is that they represent system level problems and are generally thrown by the Java Virtual machine or environment instead of the application. +Applications should generally not attempt to catch or handle them. + +All errors in Java inherit from the `Error` class.