• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling own Exceptions

 
Abubacker Siddik
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Im new to coderanch. I want to know.. can we throw an exception class which is abstract??
 
Campbell Ritchie
Sheriff
Pie
Posts: 47296
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47296
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47296
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks dude, I understood things well now.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47296
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic