[amp_mcq option1=”will override the base class function” option2=”will cause an error message to display” option3=”will be overridden by the base class function” option4=”will execute immediately often the base class function executes” correct=”option1″]
The correct answer is A. will override the base class function.
When a function in a derived class has the same name as a function in the parent class, the function in the derived class overrides the function in the parent class. This means that the function in the derived class will be called instead of the function in the parent class, when a reference or pointer to the derived class is used.
Option B is incorrect because it is not an error to have a function in a derived class that has the same name as a function in the parent class. The function in the derived class will override the function in the parent class.
Option C is incorrect because the function in the derived class will override the function in the parent class, not the other way around.
Option D is incorrect because the function in the derived class will only be called if a reference or pointer to the derived class is used. If a reference or pointer to the parent class is used, the function in the parent class will be called.