• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Exception

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear,
I am not very clear about "Functional Difference Of CHECKED-EXCEPTION & UNCHECKED-EXCEPTION".
*Overriding method can throw checked exception only when its super class is throwing an exception in range(None or all-as super or sub excption as super).But it is happning with IOException/SQLException...?

Please elaborate it.
Thanking You,

With Regards,
Sajid.
Waiting for reply.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An IOException is a checked Exception. If your super class method throws this Exception , then your sub class method can catch anything narrower than IOException or it can catch IOException, or any unchecked Exception. Remember that RuntimeExceptions and Errors are not checked.
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exception Handling.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Remember that RuntimeExceptions and Errors are not checked.


This means that in subclass overriding method can throw for ex ArithmeticException as its Runtime Exception even though orignal method is not declaring that.
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


1. move() method in Animal class is not throwing an exception, then move() method in Mammal class at max can throw java.lang.RuntimeException or its sub-classes. (dats is only unchecked).

2. move() method in Animal class throws say ArrayIndexOutOfBoundException, sub class method can throw same or even its super class exception provided that must be unchecked.

3. If super class method throws say IOException (checked), then sub class method can throw none or any unchecked or IOException or sub classes of IOException but not super classes of IOException because IOException is checked...

Thanks & Regards

Naseem
[ July 29, 2006: Message edited by: Naseem Khan ]
reply
    Bookmark Topic Watch Topic
  • New Topic