I thought I understood inheritance and polymorphism, but I was given this question, and I can't, for the life of me, figure out what the proper answer is or what they're trying to get at:
The process of determining which method in a class hierarchy should execute is known as:
- a) inheritance
- b) polymorphism
- c) is-a
- d) has-a
- e) parent class
Looking at each of the terms, none of them seem like the proper answer.
Inheritance is just when a class automatically gets the public variables and methods in its parent class. So this clearly isn't the right answer.
Polymorphism allows us to write one method to handle object A, and as a result will work with everything that extends object A (or continues to extend it, IE Object B extends Object A. Object C extends Object B, etc) So this clearly isn't the right answer!
Is-a: This doesn't even make any sense. Is-a is just used to declare that a class is an instance of its parent class (dog is-an animal), so it inherits its public variables and methods. I don't see how this is "determining which method in a class hierarchy should execute"
Has-a: I'm not too familiar with this, but it's essentially composition, where Object-A has-a Object B, but object-B isn't an instance of Object A. This doesn't seem like the right answer either
Parent Class: This is just the base class, if we trace the tree of inheritance up, the top of the tree is the parent class.
Can someone please explain which term can also be defined as "The process of determining which method in a class hierarchy should execute is known as"?
Am I not understanding one or more of the terms? Is this simply a poorly worded question?