what is difference between throw and throws in exception?

Answer Posted / basha

throw & throws is a keyword in Exceptions.
throw is to throw the exception defined by User.
Ex:if user enter wrong pin number,it shows error
(Exception). This s the exception used to throw it.

And throws is that which will throw the error as the Cash
Dispenser not having the cash to dispense. This type of
error(exception) is defined by throws keyword.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

In how many ways we can create threads in java?

635


How do you reverse sort a list in java?

517


What is exception propagation?

594


What is the Scope of Static Variable?

734


Can inner class extend any class?

600






What is boolean data type in java?

570


What is an object's lock and which object's have locks in java programming?

571


How to display arraylist values in java?

491


From the two, which would be easier to write: synchronization code for ten threads or two threads?

619


Difference between object and reference?

687


Does substring create a new object?

530


Explain throw keyword in java?

617


Can a final variable be initialized in constructor?

492


How many types of memory areas are allocated by JVM in java?

599


What is the difference between exception and error in java?

495