Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Review the code below and then determine which method meets the following criteria: is being run in the main method is an overridden method from
Review the code below and then determine which method meets the following criteria: is being run in the main method is an overridden method from a super class prints out "Dogs can walk and run"
class Animal { public void move() { System.out.println("Animals can move"); } } class Dog extends Animal { public void move() { System.out.println("Dogs can walk and run"); } } public class TestDog { public static void main(String args[]) { Animal a = new Animal(); // Animal reference and object Animal b = new Dog(); // Animal reference but Dog object a.move(); // runs the method in Animal class b.move(); // runs the method in Dog class } }
move() | ||
main()
| ||
a.move()
| ||
b.move() |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started