+ 1

I want an example that shows me inheritance in Java because Im confused ...!

8th Jul 2020, 4:19 PM
Eilaf Abd Almjeed
Eilaf Abd Almjeed - avatar
3 ответов
+ 3
abstract class Animal { abstract void talk(); } class Dog extends Animal { public void talk() { System.out.println("woof!"); } } class Cat extends Animal { public void talk() { System.out.println("meow!"); } } class MyClass { public static void main(String[ ] args) { Dog dog = new Dog(); Cat cat = new Cat(); dog.talk(); cat.talk(); } } >>> woof! meow!
8th Jul 2020, 4:38 PM
Shen Bapiro
Shen Bapiro - avatar
+ 1
Thanks ♥
8th Jul 2020, 4:45 PM
Eilaf Abd Almjeed
Eilaf Abd Almjeed - avatar
0
lvl 1 crook this is awesome thanks 😊
8th Jul 2020, 4:47 PM
Eilaf Abd Almjeed
Eilaf Abd Almjeed - avatar