what is difference between throw and throws in exception?

Answer Posted / ritesh

Whenever we want to force an exception then we use throw keyword.Moreover 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.
Whereas when we know that a particular exception may be thrown or to pass a possible exception then we use throws keyword

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is variable explain with example?

574


Is java a super set of javascript?

589


when you will synchronize a piece of your code? : Java thread

533


Is 0 true or false in java?

520


What is java autoboxing?

541






difference between byte stream class and character stream class?

4090


Why java is a platform independent? Explain

536


Differentiate between == and equals().

602


What is style and indentation?

558


How do I stop concurrentmodificationexception?

513


Are arrays static in java?

590


What are the actions that can occur when a thread enters blocked state?

585


What is the locale class in java programming?

531


How dead lock situation occurs in java and how you can identify it?

549


how its run?

573