TypeScript Override
class Boy {
name : string
about() : void {
console.log(this.name +" is an intelligent boy..")
}
}
class Student extends Boy {
rollnumber : number;
marks: number;
constructor(rollnumber : number, marks : number,
name1 : string){
super();
this.rollnumber = rollnumber
this.name = name1
this.marks = marks
}
displayStudentInformation() : void {
console.log("Name : "+ this.name +", Roll Number : " +
this.rollnumber +",
Scores : " + this.marks + " out of 100" )
}
about() : void {
// Invokes parent class about() method here also.
super.about();
console.log(this.name + " scores well...")
}
}
let student = new Student(2, 96, "Rohit");
student.displayStudentInformation();
student.about();
Vansao Hang