CodesJava

Easy learning with example program codes

TypeScript abstract class tutorial


TypeScript Abstract Class:

Abstract class is a way of implementing 0 to 100% abstraction. A class declared with abstract keyword is known as an abstract class. An abstract class may or may not contain abstract method. Abstract classes cannot be instantiated.

Syntax:

abstract class className {
   // declare fields
   // declare abstract/non-abstract methods
}

Abstract method:

A method with no implementation i.e. without braces and followed by a semicolon.

Syntax:

abstract return_type methodName();

Example:

abstract class Department {
 
    constructor(public name: string) {
    }
 
    printName(): void {
        console.log("Department name: " + this.name);
    }
 
    abstract printMeeting(): void; 
}
 
class AccountingDepartment extends Department {
 
    constructor() {
        super("Accounting and Auditing"); 
    }
 
    printMeeting(): void {
        console.log("The Accounting Department meets each Monday at 10am.");
    }
 
    generateReports(): void {
        console.log("Generating accounting reports...");
    }
}
 
let department: Department;
department = new AccountingDepartment();
department.printName();
department.printMeeting();

Try it:

JS Bin on jsbin.com

TypeScript Tutorial

TypeScript Overview.
Typescript vs Javascript.
Typescript let vs var.
TypeScript Hello World.
Typescript Data Types.
Typescript Variable Declaration.
TypeScript operators list.
TypeScript Arithmetic Operators.
TypeScript Comparison Operators.
TypeScript Bitwise Operators.
Typescript Logical Operators.
TypeScript Assignment Operators.
Typescript Conditional Operator.
Typescript String Operator.
Typescript typeof Operator.
TypeScript control statements.
TypeScript Switch Statement.
TypeScript for loop.
TypeScript for in loop.
TypeScript while loop.
TypeScript do while loop.
Typescript for loop break.
TypeScript for loop continue.
Typescript function.
Typescript returning function.
Typescript parameterized function.
Typescript function optional parameter.
Typescript rest parameters.
Typescript default parameters.
Typescript anonymous function.
Typescript function constructor.
Typescript Arrow/Lambda function.
Typescript function overloading.
TypeScript number object.
TypeScript string object.
TypeScript boolean object.
TypeScript date object.
TypeScript math object.
TypeScript array object.
TypeScript tuples.
TypeScript union type.
TypeScript interface.
TypeScript interface inheritance.
TypeScript interface multiple inheritance.
TypeScript class.
Typescript class inheritance.
Typescript class interface.
TypeScript abstract class.
TypeScript object.
TypeScript duck typing.
TypeScript NameSpace.
TypeScript Multi-file namespaces.
TypeScript module.
TypeScript ambient module.


Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap