how can u handle runtime exceptions in java plz explain
with examples briefly?

Answer Posted / ravibeli

We can handle runtime exceptions also. But it cost a lot to developer, he has to pay his attention to know exactly which are the list of exceptions can come the execution block.

Example:

public class OrderNotFoundException extends RunTimeException {
pulbic OrderNotFoundException(){
super();
}
pulbic OrderNotFoundException(String msg){
super(msg);
}
}

public Order getOrderDetailById(Long id) throws OrderNotFoundException {
try {
OrderDAO orderDao = new OrderDAO();
Order order = (Order)orderDao.getOrderById(id);
} catch (){
throw new OrderNotFoundException();
}
return order;
}

Is This Answer Correct ?    7 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is import javax swing * used for?

708


What is the use of jcomponent class in swing?

735


Why swing is better than awt?

715


Why swings are used in java?

679


What is the difference between invokeAndWait() and invokeLater()?

767






What is container in java swing?

725


What is the difference between swing and awt in java?

715


How to render an html page using only swing.

741


What is Java Swing?

784


What is java swing package?

665


How to reload a jframe in java swing?

746


Which package is needed for swing components?

637


Explain the difference between awt and swt.

741


How to perform action on button in java swing?

673


What are the containers available in swing?

714