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.

Replies

  • manishsvkumarsingh
    manishsvkumarsingh
    GOOD CONCEPT #-Link-Snipped-#

You are reading an archived discussion.

Related Posts

A computer engineer by degree, this Indore girl has done it all. Right from working at various levels in the financial services sector, to donning the hat of leadership positions...
I'm doing M.tech in Embedded System Design, and I want to do my research/project in the field of Railway Signalling. Can anybody suggest me some railway related topics for M.tech...
I have to present a seminar in my college on this topic, so please help me to understand how power is generated, and distributed on an ship.
I was wondering if anyone has a solution or may be direct me to right person(s) who can help me solve the problem statement that I am currently dealing with....
LINE Corporation has unveiled the lightweight variant to its popular messenger app in 11 countries including India, Pakistan, Vietnam and Saudi Arabia. Called 'LINE Lite', the new version is said...