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

Hello Everyone.. I m trying to develop a java swing application where i can display a doc file Jeditorpane or Jtextpane.

1755


Why are swing components called lightweight components?

478


Is swing still used?

499


How to add calendar in java swing using eclipse?

777


Which window contains the swing controls?

530






What is java swing package?

511


Is swing an api?

541


What are differences between swing and awt?

526


What are the components of swing?

530


What is difference between awt and swing?

567


What is a component in swing?

505


What is swing and its features in java?

492


What is the process of setting the layout manager?

589


What is the purpose of serialization in swings?

544


What are the containers available in swing?

524