Answers for "Show the difference between this() and super() with help of a code"

0

Show the difference between this() and super() with help of a code

class Animal {
  void eat() {
    System.out.println("animal : eat");
  }
}

class Dog extends Animal {
  void eat() {
    System.out.println("dog : eat");
  }
  void anotherEat() {
    super.eat();
  }
}

public class Test {
  public static void main(String[] args) {
    Animal a = new Animal();
    a.eat();
    Dog d = new Dog();
    d.eat();
    d.anotherEat();
  }
}
Posted by: Guest on November-21-2021

Code answers related to "Show the difference between this() and super() with help of a code"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language