answersLogoWhite

0


Best Answer

In Java there are two main types of Exceptions.

* Checked Exceptions - The ones that can be checked & handled in our code. Ex: I/O Exception, SQL Exception etc. In most cases, the compiler itself forces us to catch & handle these exceptions

* Un-checked Exceptions - The ones that we cannot & should not handle in our code. Ex. Null Pointer Exception

The java.lang.Throwable is the super class of all errors and exceptions in Java. Only objects of this class can be thrown & caught and handled by try-catch blocks.

Ex:

try {

.....

.....

} catch (Exception e){

...

} finally {

...

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Describe the JAVA throwable class hierarchy and types of exceptions?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the top most class in Exceptions?

All exception types are sub classes of the built-in class Throwable. so at the top most position it is Throwable --- under this comes two branches Exception and Error.


How many constructors does class Exception have?

The Exception class has 4 constructors. They are: a. Exception() b. Exception(String arg) c. Exception(String arg, Throwable arg1) d. Exception(Throwable arg)


What is the difference between catch exception e catch error err and catch throwable t?

In Java it is related to the class hierarchy of exceptions. Throwable is the root object of the heirarchy, and both Exception and RuntimeError subclass it. Methods include a "throws" clause in their signature to indicate errors of type "Exception" that can be thrown in the body of the method and returned to the caller. Errors of type RuntimeError do not need to be reported in the throws clause.Exceptions are also called "checked" errors, and RuntimeErrors are called "unchecked." This simply means that methods that throw checked errors must declare them in the signature.* Exception: this is a "checked" error. Usually, this is some sort of data error that can be handled by the method. An example is FileNotFoundException - some code didn't an expected file, but the program may be perfectly capable of going on.* Error: A more serious problem that a program probably can't deal with. An example is OutOfMemoryError - when there is no more memory, there isn't much you can do about it and not much point in continuing.* Throwable: Superclass of both Error and Exception.So the main difference is that* 'catch Exception' will catch just exceptions (the problems you might deal with)* 'catch RuntimeError' will catch just errors (the problems you probably can't deal with)* 'catch Throwable' will catch all errors.Generally, you want to catch Exception or Throwable, but not RuntimeError. You will only want to catch Throwable if there is a requirement that the method never throw an error back to the caller.See related link to the Java API, and browse the documentation and subclasses of Throwable.


Class hierarchy is a fundamental concept of object oriented programs explain what this term means with reference to inheritance abstraction and instantiation?

Class hierarchy is a term used in Java. It is used for identifying the inheritance hierarchy or the parent class relationships Ex: Public class B extends C { } Public class A extends B { } Here if we take the class hierarchy for class 'A' it would be A


Why is the top level class is considered the largest class in a class hierarchy?

I wouldn't consider it any larger than other classes - it is just the top of the hierarchy.

Related questions

What is the top most class in Exceptions?

All exception types are sub classes of the built-in class Throwable. so at the top most position it is Throwable --- under this comes two branches Exception and Error.


How many constructors does class Exception have?

The Exception class has 4 constructors. They are: a. Exception() b. Exception(String arg) c. Exception(String arg, Throwable arg1) d. Exception(Throwable arg)


What is the difference between catch exception e catch error err and catch throwable t?

In Java it is related to the class hierarchy of exceptions. Throwable is the root object of the heirarchy, and both Exception and RuntimeError subclass it. Methods include a "throws" clause in their signature to indicate errors of type "Exception" that can be thrown in the body of the method and returned to the caller. Errors of type RuntimeError do not need to be reported in the throws clause.Exceptions are also called "checked" errors, and RuntimeErrors are called "unchecked." This simply means that methods that throw checked errors must declare them in the signature.* Exception: this is a "checked" error. Usually, this is some sort of data error that can be handled by the method. An example is FileNotFoundException - some code didn't an expected file, but the program may be perfectly capable of going on.* Error: A more serious problem that a program probably can't deal with. An example is OutOfMemoryError - when there is no more memory, there isn't much you can do about it and not much point in continuing.* Throwable: Superclass of both Error and Exception.So the main difference is that* 'catch Exception' will catch just exceptions (the problems you might deal with)* 'catch RuntimeError' will catch just errors (the problems you probably can't deal with)* 'catch Throwable' will catch all errors.Generally, you want to catch Exception or Throwable, but not RuntimeError. You will only want to catch Throwable if there is a requirement that the method never throw an error back to the caller.See related link to the Java API, and browse the documentation and subclasses of Throwable.


What class begins java class hierarchy?

Class


Class hierarchy is a fundamental concept of object oriented programs explain what this term means with reference to inheritance abstraction and instantiation?

Class hierarchy is a term used in Java. It is used for identifying the inheritance hierarchy or the parent class relationships Ex: Public class B extends C { } Public class A extends B { } Here if we take the class hierarchy for class 'A' it would be A


Why is the top level class is considered the largest class in a class hierarchy?

I wouldn't consider it any larger than other classes - it is just the top of the hierarchy.


Which class of hierarchy do humans belong to?

Biologically? Humans are in class Mammalia.


How did the Egyptian social hierarchy start?

Pharaoh higher class middle class lower class


What is the class hierarchy in dbms?

In a relational database management system (RDBMS), the class hierarchy typically includes the following levels: database server, databases, tables (or relations), columns (or attributes), and rows (or tuples). The database server manages connections, access control, and query processing. Databases contain tables, which store data arranged in rows and columns. Columns define the attributes, while rows represent individual records.


What is the difference between throw and throws in Java?

Throw is used to actually throw the exception, whereas throws is declarative for the method. They are not interchangeable.public void myMethod(int param) throws MyException{if (param < 10){throw new MyException("Too low!);}//Blah, Blah, Blah...} The Throw clause can be used in any part of code where you feel a specific exception needs to be thrown to the calling method.If a method is throwing an exception, it should either be surrounded by a try catch block to catch it or that method should have the throws clause in its signature. Without the throws clause in the signature the Java compiler does not know what to do with the exception. The throws clause tells the compiler that this particular exception would be handled by the calling method.


What is hierarchy in java?

The top level class in Java is class Object. Every other class inherits from Object and therefore Object is the top most in the class hierarchy. If you extend a class from Object such as class Animal and further extend Animal with class Dog then the hierarchy is as follows: Object | Animal | Dog Code for this hierachy is as follows: class Animal { } class Dog extends Animal { } We don't need to write class Animal extends Object because every class extends from Object so it does not need to be stated.


Which highest level event class of the event delegation model?

The java.util.EventObject class is the heighest-level class in the event-delegation model class hierarchy.