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
Why java is not 100% object-oriented?
Difference between linkedlist and arraylist.
List out five keywords related to exception handling ?
What are byte codes?
Explain the difference between comparator and comparable in java?
How does compareto work in java?
Can we declare a constructor as final?
Differentiate between array list and vector in java.
Why isn’t there operator overloading?
What is a java applet? What is an interface?
Can you access non static variable in static context?
What is contractor means and methods?
If a method is declared as protected, where may the method be accessed in java programming?
Does substring create a new object?
What is the size of a string in java?