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

how many types of Inheritance?

902


What are jee technologies?

732


What are pass by reference and pass by value?

683


Is hashset ordered java?

790


What is string in java with example?

670






What is continuity of a function?

717


What is stringbuffer in java?

766


What is array size in java?

679


Why java is considered dynamic?

914


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

812


Can you sort a string in java?

664


What does opcode mean?

757


What is the difference between import java.util.date and java .util?

786


What is the maximum size of a string in java?

726


Define how destructors are defined in java?

751