What is abstract class in TypeScript?
Michael Gray
Updated on May 01, 2026
A TypeScript Abstract class is a class which may have some unimplemented methods. These methods are called abstract methods. We can't create an instance of an abstract class. But other classes can derived from abstract class and reuse the functionality of base class.
What is the purpose of abstract class in TypeScript?
Introduction to TypeScript abstract classes. An abstract class is typically used to define common behaviors for derived classes to extend. Unlike a regular class, an abstract class cannot be instantiated directly.What is an abstract class?
Abstract class: is a restricted class that cannot be used to create objects (to access it, it must be inherited from another class). Abstract method: can only be used in an abstract class, and it does not have a body. The body is provided by the subclass (inherited from).Does TypeScript support abstract class?
TypeScript has supported abstract classes since 2015, which provides compiler errors if you try to instantiate that class. TypeScript 4.2 adds support for declaring that the constructor function is abstract.What is abstract class purpose?
The purpose of an abstract class is to provide a blueprint for derived classes and set some rules that the derived classes must implement when they inherit an abstract class. We can use an abstract class as a base class and all derived classes must implement abstract definitions.Abstract Class Basics in TypeScript
Where is abstract class used?
Explanation: Abstract class is used to design base class because functions of abstract class can be overridden in derived class hence derived class from same base class can have common method with different implementation, hence forcing encapsulation.What is difference between abstract class and interface in TypeScript?
A bigger difference in TypeScript is that (abstract) classes are available at runtime, while interfaces are compile time only. This means that you cannot, for example, use instanceof with interfaces.What is polymorphism in TypeScript?
Polymorphism is the ability to create a class that has more than one form. Or in other words, classes have the same methods but different implementations.What is getter and setter in TypeScript?
Introduction to TypeScript Getters and SettersThe getters and setters allow you to control the access to the properties of a class. For each property: A getter method returns the value of the property's value. A getter is also called an accessor. A setter method updates the property's value.
What is the difference between abstraction and encapsulation?
Abstraction is the method of hiding the unwanted information. Whereas encapsulation is a method to hide the data in a single entity or unit along with a method to protect information from outside. We can implement abstraction using abstract class and interfaces.What is abstraction in OOP?
What is Abstraction in OOP? Abstraction is the concept of object-oriented programming that “shows” only essential attributes and “hides” unnecessary information. The main purpose of abstraction is hiding the unnecessary details from the users.What is an abstract in programming?
Abstraction is used to hide background details or any unnecessary implementation about the data so that users only see the required information. It is one of the most important and essential features of object-oriented programming. Pre-defined functions are similar to data abstraction.Does abstract class extend or implement?
Implementation: Abstract class can provide the implementation of the interface. Interface can't provide the implementation of an abstract class. Inheritance vs Abstraction: A Java interface can be implemented using the keyword “implements” and an abstract class can be extended using the keyword “extends”.What is encapsulation in TypeScript?
Implement encapsulation in TypeScriptA key aspect of object-oriented programming, encapsulation enables you to perform what's called “data hiding”. It's necessary to hide certain data so that it's not changed accidentally or purposefully by other components or code in the program.