wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes why can't we instantiate abstract class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why can Watch "why can New topic

why can't we instantiate abstract class

pavan Kumar

Joined: Jan 20, 2005
Posts: 6
we can instantiate Interface,but why can't we intantiate abstract class.
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
You can't instantiate an interface.
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
You can't instantiate an interface. Whatever you can do with an interface, you can do with an abstract class, too - such as using it as the base for an anonymous inner class. (Well, short of inheriting more than one of it, of course.)

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
if you could instantiate it it wouldn't be abstract...

Lionel Badiou
Ranch Hand

Joined: Jan 06, 2005
Posts: 140
Hi Pavan,

Just few words... An abtract class is a normal one, but additionnaly the class' designer declare that nobody can instanciante it. Abstract classes are used to describe basic concepts of an OO hierarchy. This is mainly a convenient way to declare general services a classes hierarchy provide.

So it doesn't make sense to instanciate an abtract class, nor to try to modify a constant(basically a variable you state to be unmodifiable)

Best regards,

Lionel Badiou
CodeFutures Software
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Often an abstract class also has abstract methods (i.e. methods that are declared but have no body). It just wouldn't make sense to allow you to instantiate these since some of the functionality is missing.


Java API Documentation
The Java Tutorial
I agree. Here's the link: http://aspose.com/file-tools
subject: why can't we instantiate abstract class
Similar Threads
Difference between abstract classes and interfaces
why abstract class can have constructors
about abstract local classes
Why HttpServlet is abstract ?