what is difference between throw and throws in exception?

Answer Posted / gourav shivhare

The throw keyword denotes a statement that causes an exception to be initiated. It takes the Exception object to be thrown as an argument. The exception will be caught by an enclosing try-catch block or propagated further up the calling hierarchy. The throws keyword is a modifier of a method that denotes that an exception may be thrown by the method. An exception can be rethrown.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we declare main () method as non static?

524


State the merge-sort principle and its time complexity.

575


Can a string be null?

546


Can we instantiate interface in java?

676


Explain about doubly linked list

621






How does arrays sort work in java?

604


What is floating data type?

541


What is a ternary operator in java? What is an interface?

553


Why is it called buffering?

585


What is loop in java?

537


Can this keyword be used to refer static members?

551


Can one thread block the other thread?

610


Can we rethrow the same exception from catch handler?

569


What is a text string?

627


Given a singly linked list, find the middle of the list in a single traversal without using temporary variable.

615