File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Handling own Exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Handling own Exceptions" Watch "Handling own Exceptions" New topic
Author

Handling own Exceptions

Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
Hi, Im new to coderanch. I want to know.. can we throw an exception class which is abstract??
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38033
    
  22
Welcome to JavaRanch

The answer is, yes of course you can.
The answer is, no of course you can't.

Have you tried it? What happened? That is the sort of thing we have never tried, so we don't know whether it would work.
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
ya i know we can instantiate an abstract class but when we handle own exceptions, we cant throw an abstract class as an exception class. thats you mean.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38033
    
  22
The situation is exactly the same for all classes. You can instantiate an abstract class as an anonymous class, and then use that instance. That applies to all classes, including Exceptions.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38033
    
  22
If you don't write an anonymous class, then you can't instantiate an abstract class. That applies to all kinds of class, including Exceptions.
Abubacker Siddik
Ranch Hand

Joined: Aug 12, 2009
Posts: 90
thanks dude, I understood things well now.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38033
    
  22
 
Don't get me started about those stupid light bulbs.
 
subject: Handling own Exceptions
 
Similar Threads
writing from a jar
WA #1.....word association
counting algorithm
void return type in JSP expression
why JMX can not stop