Question

How does the computer call a method in a class Rat (which inherits from Animal) if...

How does the computer call a method in a class Rat (which inherits from Animal) if all I have is an Animal pointer? (Don't answer as a user. How does it work technically.)

Homework Answers

Answer #1

Here Animal is Parent class and You have the pointer for the class Animal so you can create Object for class Rat and assign that object to the pointer and cal the method in the class RAT. But here the condition is method which your are calling must present in Animal class as abstract or normal method than only you can call using Animal Pointer This is called Dynamic Polymorphism. Otherwise we can't call

NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.

I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Which statement about Matlab handle class is true? Select one: a. Each handle class inherits from...
Which statement about Matlab handle class is true? Select one: a. Each handle class inherits from a value class. b. It is not possible to derive subclasses from handle classes. c. A handle class constructor returns a handle object that is a reference to the object created. d. If you reassign handle class variable Matlab creates an independent copy of the original object. e. The handle class is a superclass for all Matlab classes.
Java Program Implement a class called AnimalTrainer. Include the following data types in your class with...
Java Program Implement a class called AnimalTrainer. Include the following data types in your class with the default values denoted by dataType name : defaultValue - String animal : empty string - int lapsRan : 0 - boolean resting : false - boolean eating : false - double energy : 100.00 For the animal property implement both getter/setter methods. For all other properties implement ONLY a getter method Now implement the following constructors: 1. Constructor 1 – accepts a String...
4. Programming Problem: In this problem we will keep the Mechanism interface and the two classes...
4. Programming Problem: In this problem we will keep the Mechanism interface and the two classes Car and Computer from the previous problem. In addition, we will add a new class called Mechanic. We will also create a new TestMechanic class that will contain the main method. Create a class called Mechanic with following instance variable and constants: private int cost; public static int TEST_PRICE = 10; public static int REPAIR_PRICE = 50; Have a default constructor that will set...
I have the below homework problem for a python programming class, and i really need some...
I have the below homework problem for a python programming class, and i really need some help!! First, take a set of 6 grades from a user and average them. Provide the average to the user. You need to check to make sure the grades are within the normal range. If the grade is less than 0 or more than 100, issue a warning to the user. You don't need to take the grade again, just let the user know....
Kerberos For each question, describe how the attack occurs and then write how Kerberos can be...
Kerberos For each question, describe how the attack occurs and then write how Kerberos can be used to defend against the attack. Please label each question, then write the answer. For example, Question 1), then write answer. Also, please don't post solution unless all 5 questions are answered. I appreciate the help. Thank You Question 1.) A user gains access to a particular workstation and pretends to be another user from that workstation. Question 2.) An eavesdropper obtains the IP address of...
Write the Game class, Java lanuage. A Game instance is described by three instance variables: gameName...
Write the Game class, Java lanuage. A Game instance is described by three instance variables: gameName (a String), numSold (an integer that represents the number of that type of game sold), and priceEach (a double that is the price of each of that type of Game). I only want three instance variables!! The class should have the following methods: A constructor that has two parameter – a String containing the name of the Game and a double containing its price....
1. Which animal phyla are asymmetrical in their adult form? (3)                                &nbs
1. Which animal phyla are asymmetrical in their adult form? (3)                                                                            2. Which animal phyla are radially symmetrical in their adult form? (3)                                                              3. Which animal phyla are bilaterally symmetrical in their adult form? (3) 4. Which animal phyla have a complete (two opening) digestive system? (3) 5. Segmented worms belong to phylum a. Nematoda b. Mollusca c. Porifera d. Cnidaria e. Platyhelminthes f. Annelida g. Arthropoda h. Echinodermata 6. Segmented worms are a. acoelomate b. pseudocoelomate...
How does the weighted-average cost method differ from the average cost method? A. Each inventory price...
How does the weighted-average cost method differ from the average cost method? A. Each inventory price is weighted by the quantity of units purchased at a given price with the weighted-average cost method. B. An average of the inventory purchase prices is computed without regard to the quantities purchased with the weighted-average cost method. C. The average cost method assumes all inventory items have the same cost, whereas the weighted-average cost method assumes costs differ. D. The average cost method...
Please answer all of these 2. Colin is 35 years old and inherits an IRA from...
Please answer all of these 2. Colin is 35 years old and inherits an IRA from his mother, who dies prematurely at age 60 in May 2020. Which of the following statements is correct regarding his options for the inherited IRA? a. Colin does not have to take distributions until he turns 70 years old b. Colin can rollover the IRA into his own IRA c. Colin can take out the entire distribution any time within 10 years and avoid...
JAVA QUIZ Question 1 Which of the following is false about a "super" call in a...
JAVA QUIZ Question 1 Which of the following is false about a "super" call in a sub class's constructor? Select one: a. It must be the first statement in the constructor b. If you don't include it Java will c. If you don't include it you must have a 0 parameter constructor coded in the super class or no constructors coded at all in the super class d. The sub class constructor containing the super call and the called super...