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 function in java?

689


What is difference between filereader and bufferedreader?

641


Which is best ide for java?

660


What is a protected method?

739


Which number is denoted by leading 0x or 0x in java?

743






Why java is a platform independent? Explain

667


What is void keyword?

790


How can you read an integer value from the keyword when the application is runtime in java? example?

750


What is the nested interface?

713


Why for each loop is used?

649


Why we override equals() method?

691


Can we access instance variables within static methods ?

688


Explain the purpose of garbage collection in Java?

701


What things should be kept in mind while creating your own exceptions in java?

772


What is string array?

740