Explanation of Solution
Given code:
//Line 1
//Base class declaration of "Vegetable"
class Vegetable
{
#Line 2
#Define the virtual message() method
public virtual void message()
{
//Line 3
//Print the message
MessageBox.Show("I'm a vegetable.");
}
}
#Line 4
/*Derived class declaration of "Potato" which inherits base class properties. */
class Potato : Vegetable
{
#Line 5
/* overrides the base class method name "message()"
method which displays the message on the output
screen. */
public override void message()
{
//Line 6
//Print the message
MessageBox.Show("I'm a potato.");
}
}
//Line 7
/*Driver code create an object for base class */
Vegetable v = new Potato();
//Line 8
//create an object for derived class
Potato p = new Potato();
//Line 9
//call the method "message()" using base class object
v...
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
Pearson eText for Starting out with Visual C# -- Instant Access (Pearson+)
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education