Extends | Sololearn: Learn to code for FREE!

0

Extends

How can i use the (extends ) on this programm ? I can‘t open two classes in the same time. Thank you all

1/23/2022 1:10:17 PM

Mohammad

3 Answers

New Answer

+2

You can do it the normal way. Like this example : (And read Java lesson 43.1) class Animal { protected int legs; public void eat() { System.out.println("Animal eats"); } } class Dog extends Animal { Dog() { legs = 4; } } class MyClass { public static void main(String[ ] args) { Dog d = new Dog(); d.eat(); } }

+1

Thank you very match

+1

also two classes can be public in one file here (it is not standard java feature)