Question
1 . Now assume you have classes Person and Student as defined in class. Assume that you have a Person type variable that references a
1 . Now assume you have classes Person and Student as defined in class. Assume that you have a Person type variable that references a Student type object. I.e. Person p = new Student(Sally, 18); If the method sayHi() is defined in the Person class and overridden in the student class, which version of the method will be called when I write p.sayHi(), the Persons version or the Students version?
Inheritance Questions Based on the Implementation of Critters.java
https://pastebin.com/NKRN10an (Use this code)
Which methods from Critter will you override in the Bear class? (if you were to make a Bear class that had features such as color, attack, movement, etc)
Will the following cause an error: Bear b = new Critter(); Why or why not?
True or false: you will need to add a line of code that calls the method eat critters to eat food during the simulation.
True or false: The member variables in the Dragon class can be different and have no relation to the member variables in the Tiger class. (If you were to make separate Tiger and Dragon classes)
Explain how you could use a static member variable in the Bear class to keep track of the total number of Bears that had ever been created. (Note: Theres no need to actually do this in the code).
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