what difference between throw and throws in exception
handling.

Answer Posted / aravinda reddy

Whenever we want to force an exception then we use throw
keyword,throw keyword can also be used to pass a custom
message to the exception handling module i.e. the message
which we want to be printed. throw we will use at statement
level.

Whereas when we know that a particular exception may be
thrown or to pass a possible exception then we use throws
keyword. Point to note here is that the Java compiler very
well knows about the exceptions thrown by some methods so
it insists us to handle them. Method Level

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to print fibonacci series

613


What is the relationship between class and object?

527


What are the different conditional statements?

558


What is passed by reference and pass by value ?

584


What happens when you add a double value to a string?

543






Differentiate between nested and inner class in java.

559


What is the java project architecture?

1787


What does singleton class mean?

535


What is null object in java?

572


What is the replace tool?

551


How do you differentiate abstract class from interface?

530


What is unmodifiable collection in java?

511


What is entry set in java?

533


Is it compulsory for a try block to be followed by a catch block in java for exception handling?

593


Which class is used by server applications to obtain a port and listen for client requests?

491