super vs. this

  • super : used to access methods of the base class
  • this : used to access methods of the current class

superTHis1 superThis2

The third line is printing “animal : eat” because we are calling super.eat().

If we called this.eat(), it would have printed “dog : eat”.

Leave A Comment

Your email address will not be published. Required fields are marked *