+ 3
What is Exception handling?
describe it...
8 Antworten
+ 11
Exception handling is a way to make sure ur code doesn't crash when something unexpected occurs. For example u have a code that takes 2 input and returns their division e.g
int x = sc.nextInt();
int y = sc.nextInt();
int result = x/y;
An exception occurs if y=0(Arithmetic exception) which will cause the code to crash if not handled.
To handle:
try {
int x = sc.nextInt();
int y = sc.nextInt();
int result = x/y;
}
catch(ArithmeticException e){
System.out.println("Division by zero");
}
+ 6
alters the normal flow of program execution...!! ie disburbance😅😅
+ 3
you decide what program do when an error occur
+ 2
they can prevent programs from crashing
+ 1
Use "try ... catch ..." to control the exception, otherwise you will get an error.
+ 1
if you have large code in file and got exception then handle by try catch. ..no need to read whole code by compiler..
it makes efficiency in programming.
+ 1
unwanted event occurce unexcceptly to disturbs the flow of program is called exception
0
thanks...