what is difference between throw and throws in exception?

Answer Posted / ajay

Throws keyword suggests that the particular method contains
an Exception and that uncaught Exception is thrown to be
next class where it is supposed to handle(i.e.to be by next
user as he want to handle that exception in his own
way).Simply it throws uncaught exception.But Throws keyword
is used to throw only checked Exceptions and avoids compile
time errors.
And throw keyword,which is used in case of manual
Exception,throw object of corresponding exception from try
to catch just like java implicitely does in cases other than
manual Exception.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain java coding standards for variables ?

673


Why do we need data serialization?

546


What is a variable simple definition?

581


What is passing value java?

513


What are the two types of streams offered by java 8?

515






What does a za z0 9 mean?

564


What is anti pattern in cyber security?

528


Tell me the latest versions in java related areas?

586


Can static methods access instance variables in java?

579


What is functional interface in javatpoint?

516


Is void a data type?

540


What is the disadvantage of synchronization?

566


Where is const variable stored?

536


What is the synonym of string?

543


Can we declare a constructor as final?

679