Abstract class

Before abstraction let’s first understand the abstraction.


Abstraction is the process of hiding the implementation details and showing only functionality to the user. It hides the internal details.

Ways to achieve abstraction:
1. Interface
2. Abstract class

Abstract class
A class that is declared as abstract is known as an abstract class. It needs to be extended and its method implemented.It can not be instantiated.
Syntax:  abstract class {}

abstract method
A method that is declared abstract and does not have implememntation is known as abstract method.
abstract ();

Real world example of abstract class
In this example, shape is abtract class, its implementation is provided by the circle class.

abstract class shape
	abstract void draw();
class circle extends shape
	void draw(){System.out.println(" inside circle");}
class test
	public static void main(String args[])
		shape s = new circle();


  1. If there is any abstract method in a class that class must be abstract.
  2. If you extending any abstract class that class must either provide the implementation of that method or make this class abstract.
  3. If an abstract class is implementing an interface, end user might not forced to override all methods. But class extending that abstract class must implement all methods.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Post Navigation