java abstract classes tutorial

java abstract classes tutorial I this chapter we will discuss in detail about What is the Abstract class?, Advantage of Abstract class, When to define a class as an abstract, syntax of writing an abstract class, What is the abstract method?, Advantage of the abstract method, when to define a method.

Abstract class does not have any real time object. Abstract classes are a way of organizing a program.

java abstract classes tutorial

Advantages of an abstract class:

The advantage of using an abstract class is that you can group several related classes together as siblings. Grouping classes together are important in keeping a program organized and understandable.

Abstraction refers to the ability to make a class abstract in Object Oriented Programming. An abstract class cannot be instantiated. All other functionality of the class still exists, and its fields, methods, and constructors are all accessed in the same manner. We cannot create an instance of the abstract class.

If a class is abstract and cannot be instantiated, the class does not have much use unless it is a subclass. This is typically how abstract classes come about during the design phase. A parent class contains the common functionality of a collection of child classes, but the parent class itself is too abstract to be used on its own.

A  method which is declared without anybody within an abstract class is known as the abstract method.

abstract method body will be defined by its subclass

you can not define Abstract method can never be final and static

The class extends an abstract class then it must implement all the abstract methods declared in its superclass

The only abstract class can contain an abstract method.

To define some common functionalities in Abstract class and those can be used in derived classes.

Classes which contain one or more abstract methods or abstract properties, such methods or properties do not provide the implementation. These abstract methods or properties are implemented in the derived classes (Sub-classes).

Abstract methods allow run-time polymorphism

It defines behavior of subclass with dictating implementation details(encapsulation/abstraction)

Define standard or protocol.

The Example code as below:-

public class Salary extends Employee


private double salary;


public double computePay()


System.out.println(“Computing salary pay for ” + getName());

return salary/52;


//Remainder of class definition


Bodhak java tutorial LMS helps you to learn in a simple method.