what is difference between throw and throws in exception?
Answer Posted / ishan gupta
Whenever We Handle the exception through THROW we used to write
a handler for handling that Exception that is "CATCH BLOCK".It is done Explicitly by The programmer
EX:-
public static void main(String[] args) {
int a=4;
int b=0;
int c=0;
try
{
c=a/b;
throw new ArithmeticException();
}
catch(ArithmeticException o){
System.out.println("Exception Catched");
}
}
Whenever We Handle the exception through THROWS than We are not worriyng about handling the Exception As this work is done by the JVM
Ex-
public static void main(String[] args)throws ArithmeticException {
int c=4/0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are java threads?
What is an 8 bit word?
Why main method is static in java?
What are class members by default?
What is super constructor?
What are streams in java 8?
What is an example of character?
Break statement can be used as labels in java?
How do you get length in java?
Can we start a thread twice in java?
What is main function purpose?
What is pangram in java?
What is a null point?
What is a conditional equation?
How do you convert string to int in java?