Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

A doubt in exception handling

Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello friends plz get me cleared of the following doubt in exception handling.

class a
public static void main(String args[])
int i=6;
int j;
catch(Exception e)
catch(ArithmeticException s)
we know that this code will give an error since the Exception object e catches all types of exceptions,so the second catch becomes unreachable and leads to error.
my question is how does the Exception class being a super class is able to handle the exceptions of its subclasses,such as ArithmeticException and ArrayIndexOutOfBounds?
normally a super class does not have the knowledge of its subclasses.
plz mail the reply.
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't crosspost. Continue discussion here:
This will take every ounce of my mental strength! All for a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic