Exception Handling in java

Exception Handling in java

what is advantage to catch smaller exception first and then normal exception. I mean we normally catch SQLException first and then Exception.

View Answers

December 9, 2010 at 12:06 PM

Hi,

The exceptions should be from the specific to generic this is the rule to be followed.


December 9, 2010 at 6:42 PM

Thanks for the reply. Is there any advantage apart from the rule that needs to be followed?


September 3, 2012 at 1:35 PM

class MyException{ public static void main(String ar[]) { int x=0; try { System.out.println(100/x); } catch(Exception e) { } catch(ArithmeticException ae) { System.out.println("u r inside arithmetic exception"); } } } In general,Exception is the super class of all exceptions,so,we hv to give general exception first then smaller exceptions(in case,if u mention normal and smaller exceptions).....or we can directly mention smaller exceptions with out giving normal exception....or we can directly give normal exception only(without giving smaller exceptions),which can handles all exceptions under it.









Related Tutorials/Questions & Answers:
Java exception handling
Java exception handling  what are the constraints imposed by overriding on exception handling
Exception Handling - Java Beginners
Exception Handling  hi,can u pls make me understand d clear cut difference between throw n throws keyword... n how can we make our own exception..i... want to force an exception then we use throw keyword. the throw keyword is used
Advertisements
Exception Handling in java
Exception Handling in java  what is advantage to catch smaller exception first and then normal exception. I mean we normally catch SQLException first and then Exception.   Hi, The exceptions should be from
Java exception handling
Java exception handling  How does a try statement determine which catch clause should be used to handle an exception
Java exception handling
Java exception handling  How does a try statement determine which catch clause should be used to handle an exception
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
exception handling
exception handling  what is the information of exception handling?   Have a look at the following link: Java Exception Handling
Java exception handling
Java exception handling  What is the catch or declare rule for method declarations
Java exception handling
Java exception handling  What is the difference between throw and throws keywords
Java exception handling
Java exception handling  What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown within the body of the try statement
Java exception handling
Java exception handling  Does the order of placing catch statements matter in the catch block
Java exception handling
Java exception handling  What classes of exceptions may be caught by a catch clause
exception handling
exception handling  explain about exception handling
exception handling
exception handling   Give the exception hierarchy of Java.   Please visit the following links: http://www.roseindia.net/java/java-exception/exception-java.shtml http://www.roseindia.net/java/exceptions/exception
Java null pointer exception handling
Java null pointer exception handling   What is a java.lang.NullPointerException? Why do we use this exception class and when it occurs in any java... pointer exception handling What is Java NullPointerException? In Java
exception handling
exception handling  could you please tell me detail the concept of exception handling
java Exception handling - Java Beginners
java Exception handling  what is the difference between throw and throws keywords
exception handling
exception handling  What is an exception and what are the advantages of exception handling mechanism.   Java Exception Exception are the runtime errors. Advantages: 1)Exception provides the means to separate
java Exception handling - Java Beginners
java Exception handling  what is the difference between throw... an exception manually where as throws is used in the case of checked exceptions to re-intimate the compiler that we have handled the exception. For more information
Exception handling in Java Programming Examples
Exception handling in Java Programming with many Examples In this section we will explain you about the exception handling in Java and teach you how.... In this section we are presenting many examples of exception handling in Java
Exception handling in Java Programming Examples
Exception handling in Java Programming with many Examples In this section we will explain you about the exception handling in Java and teach you how.... In this section we are presenting many examples of exception handling in Java
Java : Exception Handling
Java : Exception Handling In this section we will discuss about  JAVA Exception Handling with simple example. Exception Handling : An exception... by java runtime and also generates error message ,which is displayed 
Java Exception - Exception Handling in Java
Java Exception - Exception Handling in Java  ... code you will see that how the exception handling can be done in java program... Exception Handling Example
java exception handling - Java Beginners
java exception handling  hi while i am compailing the program given below i am getting an error please help me as soon as possible import java.io.*; class insufbal extends Exception { public insufbal(String str) { super
How to make a design document for exception handling in java
How to make a design document for exception handling in java  How to make a design document for exception handling
Exception Handling in Java
occurred in the program. For more details about exception handling click on the following links Exception Handling in Java Example to show exception handling in java User Defined Exception List of Java Exception Unhandled
exception handling
exception handling  can you explain how to handle the exception in java with picture representation
Exception handling in java
Exception handling in java We are going to discus about Exception handling in java. Java program many provides exception. We are handle of error in program when during execution in a program .we are generate of exception try() block
java exception handling - Java Interview Questions
java exception handling   hi to all , this afsar i have one doubt.please clarify it. while handling exception write try catch and finally blocks. the scenario is P v S main(---) throws exception { try
Exception Handling
Exception Handling  wrtie a java program to enable the user to handle any change of divide by zero exception.   Please visit the following link: http://www.roseindia.net/java/exceptions/how-to-throw-exceptions.shtml
Exception handling
Exception handling  how to resolve file not found error exception
exception Handling
exception Handling  write a program in Java to display the names and roll numbrs of students. Initialize respective array variables for 10 students. Handle ArrayIndexOutOfBoundsException, so that any such problem doesn't cause
Exception Handling
Exception Handling  create an exception class, which thros an exception if operand is non-numeric in claculating modules. ( Use command line arguments
Exception handling
Exception handling  exception are occur at run time but when we connect to the database errors will come at compile time why
exception handling mechanism
exception handling mechanism  Explain Java's exception handling...://www.roseindia.net/java/exceptions/exception.shtml http://www.roseindia.net/java/exceptions/catching-and-handling-exceptions.shtml
exception handling
exception handling  a program to accept only three integer values as command line arguments. Print the values entered by the user. Handle ArrayIndexOutOfBoundsException and NumberFormatException by providing the applied messages
Exception Handling
Exception Handling  Hi, I really appreciate the help I have gotten,I... for the student. Create an Exception class named GradeException that contains.... In the application, throw a Grade Exception if the user does not enter a valid letter
Exception Handling
Exception Handling  Hi, I really appreciate the help I have gotten,I... for the student. Create an Exception class named GradeException that contains.... In the application, throw a Grade Exception if the user does not enter a valid letter
Exception Handling in Struts.
Exception Handling in Struts.  How you can do Exception Handling in Struts
exception handling in php - PHP
exception handling in php  i need few examples on exception handling in php
array in exception handling
array in exception handling  write java program to declare and initialize an array with the number given, 4,6,3,0,5,5,12 then the program will ask user to enter indexs number to display its value .using exception handling
Using throw keyword in exception handling in Core Java
Description: Core Java Throw Function is used for throwing the exception... exception need to be thrown from the calling method. Code for Java Throw Exception Handling:ADS_TO_REPLACE_1 package exceptionh; import java.io.*; class

Ads