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
Which collection is sorted in java?
When should the method invokelater() be used?
What is prefix of a string?
Which sort is best in java?
Can we rethrow the same exception from catch handler?
Hi.... I applied for the post of scientific officer/Engineer-SB(Programmer).Please post the syllabus and sample papers.
What is treemap in java?
What does those terms actually mean included in the j.d.k i.6?
How many bits is a string in java?
Is 0 true or false?
Which oo concept is achieved by using overloading and overriding?
What is called module?
Are arrays static in java?
Is a string literal?
Explain about class in java?