what is difference between throw and throws in exception?

Answer Posted / chandrakala

throw and throws are clauses.
throws: if we are not interested to catch the exception then we have to use throws. if any exception arises then internally JVM handles that exception.
throw: If we want to throw an exception explicitly we have to use throw.It comes under user defined exception.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the different data types in java?

538


What is method and methodology?

612


What are the differences between string, stringbuffer and stringbuilder?

535


What is mnemonic in assembly language?

565


What is float in java?

569






What is the purpose of checked and unchecked exceptions in JAVA?

571


Draw a UML class diagram for the code fragment given below: public class StringApplet extends Applet { private Label sampleString; private Button showTheString; private ButtonHandler bHandler; private FlowLayout layout; public StringApplet() { sampleString = new Label(" "); showTheString = new Button (" Show the String"); bHandler = new ButtonHandler(); layout = new FlowLayout(); showTheString.addActionListener(bHandler); setLayout(layout); add(sampleString); add(showTheString); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { samplestring.setText("Good Morning"); } } } Note: The methods need not be indicated on the diagram.

1596


Explain the difference between an Interface and an Abstract class?

640


What is the escape character in java?

524


What is the unit of plancks constant?

578


Difference between arraylist and vector.

598


What is rmi and steps involved in developing an rmi object?

576


What is methods and methodology?

542


what is deadlock? : Java thread

534


Is java 1.7 the same as java 7?

546