What is the difference between throw and throws?

Answer Posted / kanhaiya sharma

throws :- throws clause is used when programmer does
not want to handle to the exception and throw it out of a
method.

throw :- throw clause is used when programmer wants to
throw an exception explicitely and wants to handle it using
catch block. hence throws and throw is contradictory.

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which types of exceptions are caught at compile time?

560


What is use of set in java?

486


How the metacharacters are different from the ordinary characters?

562


Why local variables are stored in stack?

492


Tell me are there implementations for sorting and searching in the java libarary?

592






What is a treemap in java?

532


What are daemon Threads in java?

606


Why do we override tostring method in java?

492


What is the difference between method and means?

570


Break statement can be used as labels in java?

549


What is gc()?

574


Does java support multiple inheritances?

554


Which methods cannot be overridden in java?

532


How dead lock situation occurs in java and how you can identify it?

538


What is a control variable example?

524