What is the difference between throw and throws?

Answer Posted / suresh

mainly throw is used for user defined exceptions and throws
is used for compiler defined excetions.
Ex: if u get a NullPointer exception then we throws this
excetion to the compiler defined excetion class.

if u get malformed or ur own excetion in this time we to
throw this to our own defined excetion

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a parameter in simple terms?

564


In Java list the methods that can be overridden?

575


How many threads can java run?

563


Can a private method be declared as static?

583


What is the list interface?

612






Compare Mutex and Semaphore in java.

562


What is the use of inner class?

552


what is aggregation in java?

589


What are "methods" and "fields"?

579


What are the classes of java?

543


How many bits is a string?

530


what are abstract functions?

566


Write the algorithm to check the number non-leaf nodes in a tree.

603


What is a boolean structure?

565


Can we clone singleton object?

567