exceptions

Reply

Join Date: Feb 2008
Posts: 28
Reputation: Parsu7 is an unknown quantity at this point 
Solved Threads: 1
Parsu7 Parsu7 is offline Offline
Light Poster

exceptions

 
0
  #1
Feb 28th, 2008
Suppose i try to instantiate an abstract class then a checked exception is thrown,but who handles it or how is it handled?
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,649
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 223
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: exceptions

 
0
  #2
Feb 28th, 2008
I don't think you can instantiate an abstract class.
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 28
Reputation: Parsu7 is an unknown quantity at this point 
Solved Threads: 1
Parsu7 Parsu7 is offline Offline
Light Poster

Re: exceptions

 
0
  #3
Feb 28th, 2008
Ok that thing i know ,i just want to throw an Instantiation Exception and wants to know who handles it and how is it handled . Now the other thing which i want to know is that can we avoid an exception through throws clause?
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,649
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 223
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: exceptions

 
0
  #4
Feb 28th, 2008
  1. public void foo() throws Exception {
  2. //something happens and an exception is being thrown
  3. }
With the throws you don't avoid the exception. By adding throws you don't have to catch it, but it is thrown to the method that calls foo. Meaning that you have to write something like this:
  1. public void hoo() {
  2. try {
  3. foo();
  4. } catch (Exception e) {
  5. }
  6. }
You can omit try-catch by adding throws Exception at the declaration of hoo() but you don't avoid it because it is thrown to the one that calls hoo(). You can do that until you reach main() where you will eventually have to catch it in the end
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 28
Reputation: Parsu7 is an unknown quantity at this point 
Solved Threads: 1
Parsu7 Parsu7 is offline Offline
Light Poster

Re: exceptions

 
0
  #5
Feb 28th, 2008
Thanks a lot.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC