What is the difference between throw and throws?

Answer Posted / kanhaiya sharma

throws :- throws clause is used when programmer does
not want to handle to the exception and throw it out of a
method.

throw :- throw clause is used when programmer wants to
throw an exception explicitely and wants to handle it using
catch block. hence throws and throw is contradictory.

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the features of interfaces in java?

558


Which method you will use to create a new file to store some log data. Each time a new log entry is necessary, write string to the file in java ?

639


What is the default size of arraylist in java?

509


Is array dynamic in java?

483


What is the file extension for java?

612






What are bind parameters?

553


How do I write a self declaration?

555


What is an exception? difference between Checked and Unchecked exception in Java

560


Why set do not allow duplicates in java?

582


Can we have a try block without catch block?

571


How many types of string data types are there?

560


What are the differences between string and stringbuffer?

591


Is java same as core java?

589


Can you run java program without main method?

545


Explain java code for recursive solution's base case?

575