• 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

What makes RuntimeException and its sub classes unchecked??

 
Greenhorn
Posts: 16
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi .,

I've read that java.lang.Exception ,except RuntimeException and Error and their subclasses all Exception classes provide a category of compiler checked exceptions and if we create a custom Exception by extending Exception class our resulting class is again a Exception that will be compiler checked , but if we create exception class by extending RuntimeException or any of its subclasses the resulting exception class is an UNCHECKED exception.

can anyone plzz tell me what it is in RuntimeException class which gives its sub classes the unchecked exception behaviour.??

Thanks..
 
Marshal
Posts: 4668
305
IntelliJ IDE Clojure Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java Tutorial on Exceptions should tell you all you need to know about the different types of Exception.

You can also download the source for you favourite JDK and see how it's implemented too.
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not something in the class that makes the difference. It's just that the compiler knows to treat them differently.

Probably . As Tim says, you could check the source code to be sure. Fundamentally it doesn't matter, though. The Java Language Specification states which exceptions are unchecked, so the JDK can implement that however it wants as long as it meets the spec.
 
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Shreyas Dange wrote:
can anyone plzz tell me what it is in RuntimeException class which gives its sub classes the unchecked exception behaviour.??

Thanks..



I am not sure I understand. I think the fact that a certain RuntimeException is subclassing RuntimeException gives it the IS-A RuntimeException behaviour, i.e the unchecked exception behaviour. Or did you mean something else?

Edit : Right. After reading Matthew Brown's response, I get your question. His is the relevant answer.
 
Shreyas Dange
Greenhorn
Posts: 16
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thankyou tim and matthew
got your point..!!
 
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!