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

What is a protected void?

723


What is the default value of local and global variables?

855


What is the collections api in java programming?

786


what is the use of pojo (plain old java objects)? how it is interact with crystal reports? pls urgent

1970


What is api data?

788


What is void keyword?

879


What is the private method modifier?

831


What is stream api in java8?

798


Name few "optional" classes introduced with java 8 ?

893


What is singleton class in java and how can we make a class singleton?

849


How can we pass argument to a function by reference instead of pass by value?

852


What is flag in python?

834


Which java ide is used the most?

774


What is the this keyword?

801


How to make a non daemon thread as daemon?

835