python ruby-programming-language Smalltalk Vue.js Knockoutjs TypeScript JavaScript, OOPs JavaScript Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 8,7,6,5,4 and 2 Interview Questions and Answers Angular 4 Angular 2 AngularJs 1.x NodeJs Perl Programming R Programming RequireJs Rust Programming Backbonejs closure programming language go-programming-language kotlin-programming-language
TypeScript Inheritance and Examples

TypeScript - Inheritance and Examples

Inheritance - TypeScript is supports the concept of Inheritance.
Inheritance has ability of a program to extend existing classes to create new ones.

The extended class is called parent class or super class and the newly created classes are called child class or sub class.

Inheritance can be classified as -
1.     Single - every class can at the most extend from one parent class
2.     Multiple - doesn’t support multiple inheritances in TypeScript.
3.     Multi-level

Stayed Informed – Learn Angular 2 with TypeScript

A class captains the Public, Private, Protected and Read-only modifiers and Public by default.
You can see the below example, the class User and each members are public by default.

Example as,
class Employee {
    empName: string;
    constructor(name: string) {
        this.empName = name;

    salary(salary: number = 10000) {
        console.log('Hello, ' + this.empName + ' Your Salary -' + salary);

class Employer extends Employee {
    constructor(empName: string) {

    salary(salary = 20000) {

let empSal = new Employee("Anil");

I hope you are enjoying with this post! Please share with you friends. Thank you!!


Hi there! Welcome to my blog. My name is Anil Singh. I'm a author of this blog. For more detail about me, kindly refer to this link..
My Blogs - and
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like Powered by Blogger.
ASK Questions