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

What classes of exceptions may be caught by a catch clause in java programming?

709


How do you declare a destructor in java?

516


What is the primitive type byte?

597


What is the meaning of immutable regarding string?

528


How do you sort in descending order in java using collections sort?

512






How do you sort a string in alphabetical order in java?

537


What is a parameter used for?

528


What is argument in java?

552


What is jvm? How its run?

666


What are keywords give examples?

588


What is the main method java?

542


What is the do while loop syntax?

561


What does java stand for?

574


What is a generic code?

532


What do you mean by formatting?

555