Which is the best way of exception handling?

Answer Posted / hari

instead of using try{}catch{} blocks throw an
ApplicationException and make suclass to that class and
extend RuntimeExceptions to ApplicationException class

public void read(String name)throws ApplicationException{
badurl(name);
numberFormate(name);
}
public void badUrl(String name)throws BadUrlException{
}
public void numberFormate(String name) throws
BadNumberException{
}
ApplicationException extends RuntimeException{
}
BadUrlException extends ApplicationException{}
BadNumberException extends ApplicationException{}

Is This Answer Correct ?    16 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are java annotations?

648


What is the method overriding?

623


how a programmer confirms that the data submitted has been succesfully inserted into the database(either oracle or my sql).. How a programmer confirm if there is any problem with the program he wrote for insertion... ANS:--- >executeupdate method is having boolean return type, if anything goes wrong in data insertion or data updation, it would return false. otherwise, if it successfully inserts data into the database, it would return true NOW HOW TO I CHECK IN MY DURING EXECUTION WHETHER IT RETURNS TRUE OR FALSE... WELL IT WILL DISPLAY ANY MESSAGE OR NOT

1854


What are the main features of java?

532


What is this keyword used for?

694






What is meant by anonymous class?

596


Why main() method is public, static and void in java ?

597


Explain the private protected method modifier?

548


What are strings in physics?

547


What is n in java?

539


What is the difference between an array and an array list?

506


What is an class?

593


What is method in java with example?

493


What is formatted output in java?

503


What do you mean Abstraction in java?

611