View Feed
group-icon
Java Developers
Community of Java Developers: Get Java Programming Help from fellow Java Developers across the world.
655 Members
Join this group to post and comment.

What is Need of Abstract Class In java ?

Abstract class is a class in java which can not be instantiated. In simple terms you can not create object of that class.

Why do we need of Abstract Class then ?

Lets consider we have one parent Class Board and subclass like WhiteBoard and BlackBoard.


[​IMG] upload_2015-7-24_10-30-2

Board B =new WhiteBoard() ----- This is valid

WhiteBoard=new WhiteBoard() ---- This is valid

BlackBoard =new BlackBoard() -- This is valid

Board B =new Board() -- what type of object will be Board?What will be its color, length and width?

Will it make any sense to create object of type Board ?

Simply No.We will unable to know type of object created from Board.So in order to avoid creation of Object of Board we can mark this class as Abstract.

Abstract classes are the classes which can not be instantiated.

In above example,

Board should be declared as Abstract while designing.

WhiteBoard and BalckBoard are the concrete classes.

Concrete classes are the classes which can be instantiated.
GOOD CONCEPT @wardhaman

Share this content on your social channels -