• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
  • salvin francis
  • Frits Walraven
  • Piet Souris


Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why cant we create an object to a abstract class?
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An abstract class generalizes but does not define behavior. You can not instantiate (create) an abstract class by definition the 'how' of some behavior is yet to be defined.

Why would you want to, and maybe we can help find an alternative design?
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, welcome to the ranch!

Abstract means a couple things in Java. One is you can't make an instance. So the reason you can't make an instance is because that's what the designers decided abstract means.

The other thing it means is the class is allowed to be incomplete. It might say it implements an interface but doesn't implement all the methods. Or it might declare a method signature without a method body.

It's often handy to provide a partial implementation but require some subclass to fill in the missing bits. For example, the documentation for AbstractList says This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a "random access" data store (such as an array). It just makes life easier for someone who wants implement List.
[ October 19, 2007: Message edited by: Stan James ]
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic