Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
Programmer Certification (OCPJP)
////round-up
chao-long liao
Ranch Hand
Posts: 78
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
An exception can be caught by a catch block with an argument type that is a superclass of the thrown exception??
Ans:True
What's the meaning of the above statement?
I can't get what it says.
manasa teja
Ranch Hand
Posts: 325
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hope this code helps!!
class Exc6 { public static void main(String args[]) { int d,a; try { d =0; a = 42/d; // throws AirthmeticException System.out.println ( "a=" +a); } catch (Exception e) { } // Exception is superclass of irthmeticException and is caught here as it does not find //catch(ArithemeticException e) {} block here.. } }
[ August 07, 2002: Message edited by: Murthy Ram ]
MT
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
I like...
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Murthy,
the intention of your code is good but it won't compile unless you remove the second catch block !!
The compile error is:
Exc6.java:12: exception java.lang.ArithmeticException has already been caught catch(ArithmeticException e) {} //block here.. ^ 1 error
My Linked In
manasa teja
Ranch Hand
Posts: 325
posted 21 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I commented out that out Val!! But, I dont know, why it came down to a new line. I think, I might clicked enter there... I will edit the post again!!
MT
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Round Up question re exception& arg type
some doubts
Doubt in Exceptions - exception never thrown in body of corresponding try stmt
Exception doubt
Catching non-thrown exceptions
More...