When Do We Say An Exception is Handled

When an exception is thrown in a try block and is caught by a matching catch block, the exception is considered to have been handled. In Java, an exception is considered “handled” when it is caught and processed by an appropriate exception handler. Exception handling is a mechanism that allows you to deal with runtime … Read more

How Do You Intercept And Thereby Control Exceptions

We can do this by using try/catch/finally blocks You place the normal processing code in try block You put the code to deal with exceptions that might arise in try block in catch block Code that must be executed no matter what happens must be place in finally block In Java, you can intercept and … Read more

What is The Base Class From Which All Exceptions Are Subclasses

All exceptions are subclasses of a class called java.lang.Throwable. In Core Java, the base class from which all exceptions are subclasses is the java.lang.Throwable class. Throwable is the superclass of all errors and exceptions in the Java programming language. There are two main subclasses of Throwable: Error and Exception. All other exception classes in Java … Read more

When Do You Use Continue And When Do You Use Break Statements

When continue statement is applied it prematurely completes the iteration of a loop. When break statement is applied it causes the entire loop to be abandoned. In Java, break and continue are control flow statements used within loops. Here’s a brief explanation of when to use each: break statement: The break statement is used to … Read more

What Are The Rules For Object Reference Casting

: Casting from Old types to Newtypes Compile time rules : – When both Oldtypes and Newtypes are classes, one should be subclass of the other – When both Oldtype ad Newtype are arrays, both arrays must contain reference types (not primitive), and it must be legal to cast an element of Oldtype to an … Read more