1class Person{
2 name:string
3
4 eat():void{
5 console.log(this.name+" eats when hungry.")
6 }
7}
8
9class Student extends Person{
10 // variables
11 rollnumber:number;
12
13 // constructors
14 constructor(rollnumber:number, name1:string){
15 super(); // calling Parent's constructor
16 this.rollnumber = rollnumber
17 this.name = name1
18 }
19
20 // functions
21 displayInformation():void{
22 console.log("Name : "+this.name+", Roll Number : "+this.rollnumber)
23 }
24
25 // overriding super class method
26 eat():void{
27 console.log(this.name+" eats during break.")
28 }
29}
30
31var student1 = new Student(2, "Rohit")
32
33student1.displayInformation()
34student1.eat()