ts override method

class Person{
    name:string
 
    eat():void{
        console.log(this.name+" eats when hungry.")
    }
}
 
class Student extends Person{
    // variables
    rollnumber:number;
 
    // constructors
    constructor(rollnumber:number, name1:string){
        super(); // calling Parent's constructor
        this.rollnumber = rollnumber
        this.name = name1
    }
 
    // functions
    displayInformation():void{
        console.log("Name : "+this.name+", Roll Number : "+this.rollnumber)
    }
 
    // overriding super class method
    eat():void{
        console.log(this.name+" eats during break.")
    }
}
 
var student1 = new Student(2, "Rohit")
 
student1.displayInformation()
student1.eat()

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
typescript override method in class use the declare keyword to override in ts override a method in typescript typescript override method\ ts override types ts class method override typescript @override override typescript method typescript override method not working typescript 4 override typescript override object method typescript method override typescript methode override typescript constructor override typescript how to override method what is @override typescript typescript overirde how to override extended method in typescript override extended class method anglar override extended class method typescript typescript overwrite<> typescript child class method return object but parent class method is void typescript override methods override function typescript method overriding gtypescript typescript call inherited method typescript overrride class how to override a function in base class in typescript typescript override base method typescript how to call a public function from subclass method overloading super ts how to have function call overwritten function typescript typescript method overriding override method typescript typescript overide base class overwide methods in typescript typescript class extend overwrite a variable and call the parent function overriding typescript typescript extend class override method method overriding in typescript angular typescript override virtual method angular typescript override base method typscript override a subclass funtion typescript overwrite function typescript override parent method ts override function in class child @override typescript typescript override function overwrite class typescript overriding in typescript overwrite function from super class typescript typescript inheritance override method typescript override another class function typescript override override parent method typescript typescript override super method class extends override typescript typescript extends override method how to override base method typescript how to override angular base class method override function ts override class method typescript typescript override method of parent class overwrite method typescript class override typescript typescript function override typescript overwrite class method override method class typescript TYPESCRIPT OVERRIDING override in typescript how to override method in typescript without inheritance how to override method in typescript typescript override method angular override method override methods typescript ts override method
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source