what is difference between throw and throws in exception?

Answer Posted / ritesh

Throw :- It is possible for your program to throw an
exception explicitly, using the throw statement.

Throws :- If a method is capable of causing an exception
that it does not handle, it must specify this behavior so
that callers of the method can guard themselves against that
exception.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is string array?

584


What is a parameter in simple terms?

564


What are the differences between processes and threads?

522


What is finally and finalize in java?

598


What is a finally block? Is there a case when finally will not execute?

553






What is passing by reference in java?

543


What is the purpose of a parameter?

531


What is sortedset in java?

577


What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?

633


What is java used for?

562


Explain the difference between treeset and treemap in java?

535


What is port number in java?

596


Can a static class have a constructor?

523


How many types of constructors are used in java?

543


Can we create an object if a class doesn't have any constructor ( not even the default provided by constructor ) ?

558