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

What is balanced tree in java?

694


What is thread pool? How can we create thread pool in java?

821


When can we say that threads are not lightweight process in java?

809


What do negative exponents mean?

740


List primitive java types?

775


What is the difference between compile-time polymorphism and runtime polymorphism?

760


Print Vertical traversal of a Binary Tree.

785


Write a regular expression to validate a password. A password must start with an alphabet and followed by alphanumeric characters; its length must be in between 8 to 20.

788


What is the main difference between java platform and other platforms?

691


How are this() and super() used with constructors in java programming?

751


Does google use java?

730


What value is a variable of the string type automatically initialized?

802


Can I uninstall java?

776


What are parsers? Dom vs sax parser.

771


What is a generic code?

715