What are abstract and sealed classes in Pascal?

Object-oriented behavior in Pascal is implemented in two different ways. You can either use objects or classes to implement object-oriented programming. Both objects and classes support most of the paradigms of OOP; however, there are some notable differences between the two.

Property

Objects

Classes

Encapsulation

yes

yes

Inheritance

yes

yes

Class constructor and destructor

yes

yes

Polymorphism (virtual methods)

yes

no

Memory Allocation

Stack

Heap

A class can be declared as either sealed or abstract in Pascal.

Abstract classes

As shown in the table above, only classes support polymorphism. Polymorphism is a feature of object-oriented programming that allows different classes to have the same interface for representing different data and operations.

Abstract classes are only inherited from other classes and cannot be explicitly instantiated.

Abstract classes are created the same way as regular classes. However, using the abstract keyword before the class identifier makes it an abstract class. A class in Pascal can be declared abstract even if it does not contain any virtual methods.

Type
    className = abstract class (ParentClass)
        var1: type, var2: type, ...
        procedure method_1; abstract;
        function method_2(); return-type;
end;

Sealed classes

The keyword sealed is used when you don’t want to support inheritance in your class. It means that the class cannot be extended through derived classes or use them as a base for further child classes.

Type
    className = class sealed
        var1: type, var2: type, ...
        procedure method_1; abstract;
        function method_2(); return-type;
end;
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved