answersLogoWhite

0

Checked exceptions are exceptions which need to be handled explicitly. These are the ones which require a try-catchblock or a throws keyword.

Unchecked exceptions are exceptions which have no obligation to be handled. A NullPointerException is one common example.

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

What are the types of exception in java?

Exceptions are of two types: checked exceptions and unchecked exceptions.


What is unchecked exception?

A checked exception is an exception which the Java source code must deal with, either by catching it or declaring it to be thrown. Unchecked exceptions are all exceptions which do not follow this rule. When an unchecked exception is thrown, it is usually caused by a misuse of code - passing a null or otherwise incorrect argument. This includes classes like NullPointerException and IllegalArgumentException. Checked exceptions are generally caused by faults outside of the code itself - missing resources, networking errors, and problems with threads come to mind. These could include subclasses of FileNotFoundException, UnknownHostException, etc. The Java documentation (link below) gives some loose guidelines to follow when trying to decide which type of exception to use: "If a client can reasonably be expected to recover from an exception, make it a checked exception. If a client cannot do anything to recover from the exception, make it an unchecked exception." From a purely code-oriented point of view, a checked exception is a subclass of Exception, while an unchecked exception is a subclass of RuntimeException.


Checked and unchecked exceptions?

Unchecked exceptions : * represent defects in the program (bugs) - often invalid arguments passed to a non-private method. To quote from The Java Programming Language, by Gosling, Arnold, and Holmes : "Unchecked runtime exceptions represent conditions that, generally speaking, reflect errors in your program's logic and cannot be reasonably recovered from at run time." * are subclasses of RuntimeException, and are usually implemented using IllegalArgumentException, NullPointerException, or IllegalStateException * a method is not obliged to establish a policy for the unchecked exceptions thrown by its implementation (and they almost always do not do so) Checked exceptions : * represent invalid conditions in areas outside the immediate control of the program (invalid user input, database problems, network outages, absent files) * are subclasses of Exception * a method is obliged to establish a policy for all checked exceptions thrown by its implementation (either pass the checked exception further up the stack, or handle it somehow) It is somewhat confusing, but note as well that RuntimeException (unchecked) is itself a subclass of Exception (checked).


If a method calls another method and that method throw an exception then caller method must be throw that exception or not?

If method A calls method B and method B throws an exception, then method A must handle that exception. It does not have to throw the exception if it is in a try-catch block, but it must do something to deal with it.Note that this only applies to checked exceptions. If method B throws an unchecked exception, then A is allowed to ignore it.


Is error and exception same?

Error: Any departure from the expected behavior of the system or program, which stops the working of the system is an error. Exception:Any error or problem which one can handle and continue to work normally. Note that in Java a compile time error is normally called an "error," while a runtime error is called an "exception." Errors don't have subclasses while exception has two subclasses, they are compile time exception or checked exception (ClassNotFound Exception, IOException, SQLException etc.) and runtime or unchecked exception(ArrayIndexOutOfBounds Exception, NumberFormat Exception).


What are the different types of exception?

Exceptions in programming can be categorized into several types, primarily into checked and unchecked exceptions. Checked exceptions are those that must be either caught or declared in the method signature, such as IOException in Java. Unchecked exceptions, like NullPointerException, do not require explicit handling and typically indicate programming errors. Additionally, there are system exceptions related to runtime issues and user-defined exceptions that developers create for specific application needs.


What is the difference between a patient and a guest?

The difference is patients stay too get checked out guest visit them.


What is checked exception?

A compiler for the Java programming language checks, at compile time, that a program contains handlers for checked exceptions, by analyzing which checked exceptions can result from execution of a method or constructor. For each checked exception which is a possible result, the throws clause for the method or constructor must mention the class of that exception or one of the superclasses of the class of that exception. This compile-time checking for the presence of exception handlers is designed to reduce the number of exceptions which are not properly handled.


What is the difference between colt police positive 38spl or 38ctg?

Nothing. Have it checked by a gunsmith to be sure.


How can you tell the difference between a real and counterfeit 1909 VDB Lincoln Penny?

Have it checked by a coin dealer.


What is the difference between transporting pets as cargo and transporting pets as checked baggage?

Cargo goes with you (like a purse) and checked baggage goes in the luggage department which is probably not where you are seated.


What is the difference between hold baggage and checked baggage?

Hold baggage and checked baggage are terms used interchangeably to refer to luggage that is checked in at the airport and stored in the cargo hold of the aircraft during a flight. The main difference is that hold baggage typically refers to all luggage that is checked in, including both checked baggage and carry-on luggage, while checked baggage specifically refers to luggage that is too large or heavy to be carried onto the plane and must be checked in at the airport.