• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exceptions

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

What is the difference between JVM thrown exception and programmatically thrown exception...
the difference is kind of blur...
LIke the IllegalArgumentException(Programmatically), which is thrown when the method receives arg differently formated.But the method is actual receiveing the argument which is sent by the us!!
Similarly, ClassCastException(JVM), when coding we did the casting in a wrong manner.So it should be programmtically thrown..

But StackOverflowError, sound correct i mean as a JVM thrown..

Please dont if i sound stupid ...
Please explain
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Keday a programmatic exception is thrown explicitly using a throw clause which a JVM exception occurs at the level of the JVM without anyone throwing it. The example you gave i.e. IllegalArgumentException is thrown explicitly in methods. You can also use this technique in your programs. Take this example



But when a ClassCastException occurs, it occurs automatically. It is not thrown by using a throw statement. You are right that the exception occurs due to our programming fault this is why it has been made an unchecked exception because it can be avoided using a simple instanceof test...
 
Kedar Nath
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So can i say that Programmatically exception are those that can be thrown using throw keyword and the others as JVM exceptions???
 
Sheriff
Posts: 7136
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kedar Nath wrote:So can i say that Programmatically exception are those that can be thrown using throw keyword and the others as JVM exceptions???



JVM exceptions are the exceptions which can be thrown by the JVM, typically not by you or any other API class. But remember that we can use the "throw" keyword to raise any Exception, including Errors (Eg: NoClassDefFoundError). That keyword can be used in front of any class, which extends the Throwable class.

Cheers,

Devaka.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic