Tutorial Playlist

Java Tutorial for Beginners: A Step-by-Step Guide


What is Java: A Beginners Guide To Java

Lesson - 1

10 Reasons That Explain Why You Need to Learn Java

Lesson - 2

Java EE Tutorial: All You Need To Know About Java EE

Lesson - 3

How to Implement the Revolutionary OOPs Concepts in Java

Lesson - 4

What Is JDK? Why Do We Need It?

Lesson - 5

One-Stop Solution for Java Installation in Windows

Lesson - 6

Java Programming: The Complete Reference You Need

Lesson - 7

All You Need to Know to Implement JUnit Testing in Java

Lesson - 8

Arrays In Java: Declare, Define, and Access Array

Lesson - 9

10 Best Java Frameworks You Should Know in 2021

Lesson - 10

Top 25 Pattern Programs in Java For Printing Numbers

Lesson - 11

What Are Java Classes and Objects and How Do You Implement Them?

Lesson - 12

What is a Java Lambda Expression and How to Implement It?

Lesson - 13

The Differences Between C++ and Java That You Need To Know

Lesson - 14

What is Exception Handling in Java?

Lesson - 15

How to Get Started With Eclipse IDE?

Lesson - 16

What is Java API and The Need for Java APIs?

Lesson - 17

What Are Java Strings And How to Implement Them?

Lesson - 18

Java vs JavaScript: Know The 8 Major Differences

Lesson - 19

What is Encapsulation in Java and How to Implement It?

Lesson - 20

What is Java Interface and Why it's Needed?

Lesson - 21

Top 10 Brilliant Java Project Ideas You Need to Know

Lesson - 22

Top 60 Java Interview Questions and Answers in 2021

Lesson - 23

Java vs. Python: Which is the Best Programming Language?

Lesson - 24

What is an Abstract Class in Java and How to Implement It?

Lesson - 25

Introduction To Java Servlets and Its Life-Cycle

Lesson - 26

What is Polymorphism in Java and How to Implement It?

Lesson - 27

What Is Junit? a Look Into the Best Java Testing Framework

Lesson - 28

What Is Java JDBC? The Complete Reference

Lesson - 29

What Are Java Collections and How to Implement Them?

Lesson - 30

What is Inheritance in Java and How to Implement It

Lesson - 31
What is an Abstract Class in Java and How to Implement It?

Abstract Class in Java does the process of hiding the intricate code implementation details from the user and just provides the user with the necessary information. This phenomenon is called Data Abstraction in Object-Oriented Programming (Java).

We will learn the process of data abstraction in Java through the following docket.

  • What is an Abstract Class?
  • Features of an Abstract Class
  • Rules to Declare Abstract Class
  • Procedure to Achieve Abstraction in Java
  • The Syntax for Abstract Class
  • Interface
  • Examples for Abstract Classes
  • Interface V/S Abstract Class 
  • Advantages of Abstract Classes
  • Disadvantages of Abstract Classes

What is an Abstract Class?


Generally, an abstract class in Java is a template that stores the data members and methods that we use in a program. Abstraction in Java keeps the user from viewing complex code implementations and provides the user with necessary information.

We cannot instantiate the abstract class in Java directly. Instead, we can subclass the abstract class. When we use an abstract class as a subclass, the abstract class method implementation becomes available to all of its parent classes.

Now moving ahead, we will learn about all the outstanding features that the abstract class in Java has to offer.

Full Stack Java Developer Course

The Gateway to Master Web DevelopmentExplore Course
Full Stack Java Developer Course

Features of Abstract Class



The abstract class in Java enables the best way to execute the process of data abstraction by providing the developers with the option of hiding the code implementation. It also presents the end-user with a template that explains the methods involved.

Loose Coupling

Data abstraction in Java enables loose coupling, by reducing the dependencies at an exponential level.

Code Reusability

Using an abstract class in the code saves time. We can call the abstract method wherever the method is necessary. Abstract class avoids the process of writing the same code again.


Data abstraction in Java helps the developers hide the code complications from the end-user by reducing the project's complete characteristics to only the necessary components.

Dynamic Resolution

Using the support of dynamic method resolution, developers can solve multiple problems with the help of one abstract method.

Before moving forward, let’s first understand how to declare an abstract class.

The Syntax for Abstract Class

To declare an abstract class, we use the access modifier first, then the "abstract" keyword, and the class name shown below.


<Access_Modifier> abstract class <Class_Name> {





Examples for Abstract Classes

The following programs are a few examples of the abstract class in Java.

//Example 1:

package abstraction;

public abstract class Person {

private String Name;

private String Gender;

public Person(String nm, String Gen) {

this.Name = nm;

this.Gender = Gen;


public abstract void work();


public String toString() {

return "Name=" + this.Name + "::Gender=" + this.Gender;


public void changeName(String newName) {

this.Name = newName;


public void Exam() {

// TODO Auto-generated method stub


public void Office() {

// TODO Auto-generated method stub



package abstraction;

public class Employee extends Person {

private int EmpId;

public Employee(String EmployeeName, String Gen, int EmployeeID) {

super(EmployeeName, Gen);

this.EmpId = EmployeeID;


public void Office() {

if (EmpId == 0) {

System.out.println("Employee Logged Out");

} else {

System.out.println("Employee Logged In");



public static void main(String args[]) {

Person employee = new Employee("Pavithra", "Female", 1094826);


employee.changeName("Pavithra Tripathy");




public void work() {

// TODO Auto-generated method stub




Employee Logged In

Name=Pavithra Tripathy::Gender=Female

There are certain rules that one should know while declaring an abstract class. Let us explore them in detail.

Rules to Declare Abstract Class


The important rules that we need to follow while using an abstract class in Java are as follows:

  • The keyword "abstract" is mandatory while declaring an abstract class in Java.
  • Abstract classes cannot be instantiated directly.
  • An abstract class must have at least one abstract method.
  • An abstract class includes final methods.
  • An abstract class may also include non-abstract methods.
  • An abstract class can consist of constructors and static methods.

Procedure to Achieve Abstraction in Java


The process of Data Abstraction in Java is possible in two different ways. The first method is obviously by using the abstract class in Java, and the other one is by using an interface.



An interface in Java is a boundary between the method and the class implementing it. An interface in Java holds the method signature in it, but never the implementation of the method. In Java, we use the interface to achieve abstraction.


interface <Class_Name>{





package simplilearn;

public interface Area {

public void Square();

public void Circle();

public void Rectangle();

public void Triangle();



package simplilearn;

import java.util.Scanner;

public class shapeArea implements Area {

public void Circle() {

Scanner kb = new Scanner(System.in);

System.out.println("Enter the radius of the circle");

double r = kb.nextInt();

double areaOfCircle = 3.142 * r * r;

System.out.println("Area of the circle is" + areaOfCircle);



public void Square() {

// TODO Auto-generated method stub

Scanner kb2 = new Scanner(System.in);

System.out.println("Value of the side the square");

double s = kb2.nextInt();

double areaOfSquare = s * s;

System.out.println("Area of the square is" + areaOfSquare);



public void Rectangle() {

// TODO Auto-generated method stub

Scanner kb3 = new Scanner(System.in);

System.out.println("Enter the length of the Rectangle");

double l = kb3.nextInt();

System.out.println("Enter the breadth of the Rectangle");

double b = kb3.nextInt();

double areaOfRectangle = l * b;

System.out.println("Area of the Rectangle is" + areaOfRectangle);



public void Triangle() {

// TODO Auto-generated method stub

Scanner kb4 = new Scanner(System.in);

System.out.println("Enter the base of the Triangle");

double base = kb4.nextInt();

System.out.println("Enter the height of the Triangle");

double h = kb4.nextInt();

double areaOfTriangle = 0.5 * base * h;

System.out.println("Area of the Triangle is" + areaOfTriangle);


public static void main(String[] args) {

shapeArea geometry = new shapeArea();








Enter the radius of the circle


Area of the circle is78.55

Enter the length of the side of the square


Area of the square is100.0

Enter the length of the Rectangle


Enter the breadth of the Rectangle


Area of the Rectangle is1125.0

Enter the base of the Triangle


Enter the height of the Triangle


Area of the Triangle is250.0

Interface V/S Abstract Class 


Though an interface and abstract class perform a similar operation of data abstraction in Java, some differences separate them. The differences between them are as follows:


Abstract Class

Keyword used: interface

Keyword used: abstract

Subclasses can implement an interface

Subclasses have to extend abstract class

Multiple interfaces can be implemented

One abstract class can be extended 

Supports Multiple Inheritance

Cannot support Multiple Inheritance

Now that the differences between an interface and abstract class are clear, let us move forward. The next part will explore the crucial advantages and disadvantages that we must consider while using an abstract class in Java

Advantages of Abstract Classes

  • Abstract class in Java is highly beneficial in writing shorter codes
  • Abstraction in Java avoids code duplication
  • Abstract classes enable code reusability
  • Changes to internal code implementation are done without affecting classes

Now, let us also learn the crucial disadvantages of using an abstract class in Java.

Do you wish to become a Java Developer? Check out the Java Certification Training Course and get certified today.

Disadvantages of Abstract Classes

  • Abstraction in Java is expensive, as sometimes you need to handle cases and situations which are not always necessary
  • Object-relational impedance mismatch, in case of RDBMS
  • Object-relational mapping occurs in case of frameworks like hibernate

So, these were the important advantages and disadvantages of the abstract class in Java.

With this, we have arrived at the end of this "Abstract Class in Java" article. We hope you enjoyed understanding the essential concepts of abstract classes in Java.

Are you are interested in Java Programming Language and getting certified as a professional Java Developer? Then, feel free to explore our Java training and certification program which is curated by the most experienced real-time industry experts.

Got a question on "Abstract Class in Java"? Please mention them in the article's comment section, and we'll have our experts answer it for you at the earliest.

About the Author


Simplilearn is one of the world’s leading providers of online training for Digital Marketing, Cloud Computing, Project Management, Data Science, IT, Software Development, and many other emerging technologies.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.