Series: Exceptions

Java Exception Handling related entries

Exceptions Meaning Tutorial

Exception handling makes a language robust. This Exceptions Tutorial for Beginners explains concepts in Simple terms Examples Screenshots. Go on reading. The programmer faces two types of problems in coding – problems arising at compile-time and problems arising at runtime. Regarding compile-time problems or mistakes the compiler takes care of and ultimately does not compile …

Exceptions Meaning Tutorial Read More »

Hierarchy Exceptions Checked Unchecked Exceptions

Hierarchy of Exceptions (Checked Unchecked Exceptions) After knowing exceptions and exception handling mechanism, let us explore how many exceptions exist, are they inheriting from a common super class, any classification exists or not etc. Whenever you come across a new Java class, it is essential to know its super classes, so that, you can use …

Hierarchy Exceptions Checked Unchecked Exceptions Read More »

Java Made Clear: Difference between throws and throw

For a novice, both throws and throw keywords are very confusing. "throws" and "throw" works differently in exception handling. "throws" Keyword is used in two ways To claim the exception As an alternative for try-catch "throw" Keyword is used to throw the exception object Let us go into details. I. throws Keyword throws keyword is …

Java Made Clear: Difference between throws and throw Read More »

Rules of Exceptions in Multiple Catch Blocks

Generally, it is a good programming practice to write one problematic statement (that may throw an exception) in one try block. If the same one statement is prone to multiple problems, then it is required to write multiple catch blocks or by chance if the try block contains multiple problematic statements (generally done in rough …

Rules of Exceptions in Multiple Catch Blocks Read More »

Try with Finally Java (without Catch)

Generally, programmer writes try in combination with catch. Using finally block is optional. But it is possible to have try with finally without catch block) and compiler accepts clearly. Observe the following code. public class Demo { public static void main(String args[]) { try { System.out.println(10/0); } finally { System.out.println(); System.out.println(“From finally block”); } System.out.println(“Hello …

Try with Finally Java (without Catch) Read More »

Rules of Exceptions in Method Overriding

After knowing Rules of "Access Specifiers in Method Overriding", let us find the "Rules of Exceptions in Method Overriding". The rule says "Subclass overridden method cannot throw more checked exceptions than that of super class method". Let us explain the rule through a program for clear and easy understanding. The following program does not compile …

Rules of Exceptions in Method Overriding Read More »

Java All Exceptions Tutorial

1. Exceptions – Meaning 2. Runtime Error – Groups – Exception causes 3. Exception Handling: try – catch 4. try – catch – finally 5. Hierarchy of Exceptions – Checked/Unchecked Exceptions 6. Throwing with "throws" – Alternative to try-catch 7. Creating User-defined Exceptions – throw Keyword 8. getMessage() & printStackTrace() 9. Try – Finally (without …

Java All Exceptions Tutorial Read More »