Question: how you would create two instances of the two classes ? class Person Girl Pers double speed; public void play() { System.out.println(Person is playing); }
how you would create two instances of the two classes ?

class Person Girl Pers double speed; public void play() { System.out.println("Person is playing"); } public void sleep() System.out.println("Person is sleeping"); } } class Girl extends Person public void play System.out.println("Girl is playing"); // overriding the method and print out another text } public class Main { public static void main(String args[]) { Girl girl = new Girl(); girl.play(); // Calling the method play from Girl class girl.sleep(); // calling the method sleep from Person class }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
