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

Explain the difference between protected and default access.

518


what is interface in java? Explain

536


What do you mean by checked exceptions?

541


What is the difference between @before and @beforeclass annotation?

543


What is the difference between == and === javascript?

577






Can bool be null?

527


What are recursive functions? Give some examples?

620


Is special character in java?

616


What is linked hashset and its features?

552


What is meant by collection in java?

557


What means public static?

565


What is runtime locatable code?

870


Does java initialize arrays to zero?

511


What is the public method modifier?

547


Does treeset use compareto?

543