what difference between throw and throws in exception
handling.

Answer Posted / aravinda reddy

Whenever we want to force an exception then we use throw
keyword,throw keyword can also be used to pass a custom
message to the exception handling module i.e. the message
which we want to be printed. throw we will use at statement
level.

Whereas when we know that a particular exception may be
thrown or to pass a possible exception then we use throws
keyword. Point to note here is that the Java compiler very
well knows about the exceptions thrown by some methods so
it insists us to handle them. Method Level

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between fileinputstream and filereader in java?

555


How can an exception be thrown manually by a programmer?

506


What are the 7 types of characters?

562


What are the drawbacks of singleton class?

525


What is local class in java?

514






Java Compiler is stored in JDK, JRE or JVM?

1045


Explain about collection interface in java?

540


What is yield () in java?

478


What is a string token?

532


What is identifier give example?

547


If an object is garbage collected, can it become reachable again?

538


When do I need to use reflection feature in java?

620


What is array in java?

529


Why call by value prevents parameter value change?

577


What is difference between char array and string?

521