• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

User Defined Exception

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can we create UserDefined Exception extends CheckedException?.Is it possible?
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All classes that extend Exception (either directly or indirectly) are checked exceptions, unless they also extend RuntimeException (either directly or indirectly).
So if your class extends Exception, but not RuntimeException, then it is a checked exception.
 
rex antony
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Joanne,
For uncheckedException,Can we extends RuntimeException for the UserDefinedException.

Thanks and Regards
Rex

Joanne Neal wrote:All classes that extend Exception (either directly or indirectly) are checked exceptions, unless they also extend RuntimeException (either directly or indirectly).
So if your class extends Exception, but not RuntimeException, then it is a checked exception.

 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, you can.

All subclasses of RuntimeException are treated as Unchecked Exception.
 
Marshal
Posts: 76886
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rex antony wrote:For uncheckedException,Can we extends RuntimeException for the UserDefinedException.

Yes, but it might not be very useful.
You should find some examples in the Java™ Tutorials.
 
rex antony
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes RuntimeException comes under UnCheckedException.But what i asking that Can we create userDefinedException for UnCheckException.

Rakesh Jhamb wrote:yes, you can.

All subclasses of RuntimeException are treated as Unchecked Exception.

 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rex antony wrote:Yes RuntimeException comes under UnCheckedException.But what i asking that Can we create userDefinedException for UnCheckException.



Yes. You can extend RuntimeException, and the resulting class will be an unchecked exception class.

 
I have always wanted to have a neighbor just like you - Fred Rogers. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic