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.
Class constructor and destructor
Polymorphism (virtual methods)
A class can be declared as either
abstract in Pascal.
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 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;
View all Courses