What is the difference between throw and throws?

Answer Posted / senthil nathan

throws: If a method is not capable of handling the raised
exception and it wants the caller of the method to
handle the exception means then the method uses the
"throws" keyword... The exception raised here is
of System Exception not User Exception...


throw: If the method is capable of handling the exception
by using try&catch block then this method uses the
"throw" keyword.. It is also used to raise our own
exception.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the final class?

546


Why is the main method declared static?

578


When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?

539


Why object class is super class for every class in java?

562


What is the use of System class?

602






When the constructor of a class is invoked?

582


What is equlas() and hashcode() contract in java? Where does it used?

602


what is a green thread? : Java thread

567


Why is String immutable?

612


How to display names of all components in a Container?

2484


Write a program to reverse a number in java?

556


Can one thread block the other thread?

599


How will you invoke any external process in java?

596


How do you clear an arraylist in java?

491


What does string intern() method do?

584