What is Exception handling in Java
How do you handle run time errors please explain with an
example

Answer Posted / uv

Exceptions are handled by using "try","catch" and "finally"
block in the program.
The part of code which is suspected to give an exception is
kept under try block.
The exception is then been caught by the "catch" block. In
this way, we can avoid the abnormal termination of the
program and can also display some user friendly messages
which could guide them on how to refrain from exceptions.

finally block contains the code which is necessary to
execute like closing of connections established with
database while running the application.
finally block is always executed irrespective of the
exception.

Is This Answer Correct ?    16 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is function and method in java?

529


How to Sort Strings which are given in List and display in ascending order without using java api.

3783


Can I use % with real numbers?

568


What is thread synchronization in java?

485


Which collections are thread safe in java?

484






Explain the difference between map and flatmap stream operation?

823


Mention a package that is used for linked list class in java.

531


What is included in core java?

588


How to find the given number is a prime number or not by getting input from the user

557


Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?

609


What is an example of a boolean?

574


What is use of super keyword?

569


Does java linked list allow duplicates?

560


Explain creating threads by implementing runnable class?

593


Are arrays immutable in java?

551