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 is null data type?

532


How we can skip finally block of exception even if some exception occurs in the exception block in java?

512


What are the uses of synchronized keyword?

549


What are the limitations of procedural programming approach?

521


what is the use of pojo (plain old java objects)? how it is interact with crystal reports? pls urgent

1725






What are java annotations?

637


What is a package in java? List down various advantages of packages.

744


What are the kinds of polymorphism?

604


What is method overriding in java ?

648


What about main() method in java ?

565


Explain the importance of finally over return statement?

600


What is a Hash Table? What are the advantages of using a hash table?

599


What is variable and its types?

535


What language is java written?

527


Difference between this() and super() ?

569