File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Can I Instantiate an Abstract Class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can I Instantiate an Abstract Class?" Watch "Can I Instantiate an Abstract Class?" New topic

Can I Instantiate an Abstract Class?

Mahendran Aiyappan
Ranch Hand

Joined: Sep 05, 2005
Posts: 102
Hi guys,

I am new to Java. I want to know whether I can instantiate an Abstract class, directly or indirectly. Please provide me your useful comments.

Thanks & Regards,
Mahendran A.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15094

Mahendran A, please check your private messages. You can see them by clicking My Private Messages.

To answer your question: No, you cannot instantiate an abstract class. An abstract class is a class that is not yet "finished" - it contains methods without an implementation. A non-abstract subclass is supposed to implement those methods.

See: The Java Tutorial - Abstract Methods and Classes.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
sudhir nim
Ranch Hand

Joined: Aug 29, 2007
Posts: 212

No abstract class can not be instantiated directly, but you can declare variables of abstract class type
[ November 16, 2007: Message edited by: sudhir nim ]

[Servlet tutorial] [Servlet 3.0 Cook Book]
Rob Spoor

Joined: Oct 27, 2005
Posts: 20279

You can also create anonymous subclasses that implement all abstract methods:

These anonymous subclasses only support the constructors of the abstract class though, you can't create your own ones. If you need that kind of behaviour you need to create actual subclasses.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Can I Instantiate an Abstract Class?
It's not a secret anymore!