• 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

exceptions propagation?

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
according to SCJP 5 K&B book, in chapter 5 two minute drill.....
---uncaught exception propagate back through the call stack, starting from the method where the exception is thrown and ending with either the first method that has a corresponding catch for that exception type or a JVM shutdown (which happens if the exception gets to main(), and main() is "ducking" the exception by declaring it)


can anyone give me an example of uncaught exception propagate?
i tried google it but cant find any actual code i could understand (as an beginner)
thank yoU!
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



Now the exception will occur in method c() but theirs no handler for the exception the exception propogated to the method b() even b() doesn't have the handler next is constructor and lastly the main and main also doesn't have the handler so the exception will be passed on to JVM for handling and hence you get to see the exception having the line number and the method names of the path traverse by the exception.
 
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could be something like this:


Here in main you are calling a method that throws a checked exception, to deal with it you must either declare the exception(in main) or catch it through try/catch.
 
adam Lui
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by subodh gupta:



Now the exception will occur in method c() but theirs no handler for the exception the exception propogated to the method b() even b() doesn't have the handler next is constructor and lastly the main and main also doesn't have the handler so the exception will be passed on to JVM for handling and hence you get to see the exception having the line number and the method names of the path traverse by the exception.




so if i fix it this way...
 
Do Re Mi Fa So La Tiny Ad
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic