Hi all,

what exactly are abstracts, on what conditions are they used and how could they be used? Examples would be greatly appreciated. Thanks..
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Abstract is a class that can't be instantiated because it has one or more abstract method, Any number of Classes can extend this abstract and implment the abstract methods hence can be instantiated, refer to this article contains samples:

An formally unfinished class or method, marked with the keyword abstract. An abstact class is deliberatesly missing some or all of the method bodies. An abstract method is deliberately missing its method body. An abstract class is similar to an interface which is missing all the method bodies. An abstract class provides a base for someone to extend an actual class. You can't use new on abstract classes, but you can use abstract references, which always point to some extension of the abstract class. Interfaces are implicitly abstract as are alls their methods.

abstract class
A class that is missing definitions for one or more methods. You can't thus create an object of that class. You must first create a subclass and provide definitions for the abstract methods. Unlike interfaces, abstract classes may implement some of the methods. Though you can't instantiate an abstract class, you can invoke its static methods.

find some more information ............

Simple Example
import java.util.*;

abstract class Instrument4 {
  int i; // storage allocated for each
  public abstract void play();
  public String what() {
    return "Instrument4";
  public abstract void adjust();

class Wind4 extends Instrument4 {
  public void play() {
    System.out.println(" plays test");
  public String what() { return "Wind4"; }
  public void adjust() {}

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.