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

Can we have two methods in a class with the same name?

668


What are the types of web technologies?

648


Can we have a method name same as class name in java?

676


what is difference between equals and ==?

681


What is a native method in java programming?

625






What is a classloader in java?

624


Explain java coding standards for variables ?

757


Why main method is called first in java?

621


What is the difference between static class and normal class?

598


How many JVMs can run on a single machine and what is the meaning of Just-In-Time (JIT) compiler?

895


What is floor math?

595


What is the importance of main method in Java?

660


What do you understand by final value?

682


Why does java doesnt suuport unsigned values?

1878


How to instantiate static nested classes in java?

645