Question: Examine the following code snippet? void ask ( Question q ) { q . display ( ) ; } ChoiceQuestion inherits from Question. What happens
Examine the following code snippet?
void askQuestion q
qdisplay;
ChoiceQuestion inherits from Question. What happens if a ChoiceQuestion object is passed to the ask function?
Question options:
The function works correctly because ChoiceQuestion inherits from the Question base class.
The Question display function is called instead of the ChoiceQuestion display function that overrides the base class function.
Possibly some ChoiceQuestion data is sliced away, so the display function cannot access all the data it needs to send to standard out.
The ChoiceQuestion display function that overrides the baseclass function is called and can access all of the data members of the ChoiceQuestion object.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
