Google News
logo
TypeScript - Interview Questions
What do you understand by classes in Typescript? List some features of classes.
We know, TypeScript is a type of Object-Oriented JavaScript language and supports OOPs programming features like classes, interfaces, etc. Like Java, classes are the fundamental entities which are used to create reusable components. It is a group of objects which have common properties. A class is a template or blueprint for creating objects. It is a logical entity. The "class" keyword is used to declare a class in Typescript.
 
Example :
class Student {    
    studCode: number;    
    studName: string;    
    constructor(code: number, name: string) {    
            this.studName = name;    
            this.studCode = code;    
    }    
    getGrade() : string {    
        return "A+" ;    
    }    
}​
    
Features of a class are :
 
* Inheritance
* Encapsulation
* Polymorphism
* Abstraction
Advertisement