When a derived class contains a method or property that overrides a parent class method or property, how can you use the parent class version from within the subclass? Show an example of a derived class that overrides a parent class method, but then uses the parent class method.

What will be an ideal response?


When a derived class contains a method or property that overrides a parent class method or property, you might have occasion to use the parent class version within the subclass. If so, you can use the keyword base to access the parent class method or property. For example:
class CommissionEmployee : Employee
{
new public string GetGreeting()
{
string greeting = base.GetGreeting();
greeting += "\nI work on commission.";
return greeting;
}
}

Computer Science & Information Technology

You might also like to view...

Write a function to mirror the input picture’s leftmost 20 pixels to pixels 20 to 40.

What will be an ideal response?

Computer Science & Information Technology

JComboBoxes, JButtons and JPanels are examples of .

a) platforms b) high-level languages c) methods d) GUI components

Computer Science & Information Technology

Which vim command replaces a single character and returns to command mode automatically?

A. r B. R C. s D. S

Computer Science & Information Technology

Match each item with the correct statement below.

A. A document that shows the travel schedule of a business person. B. A file that contains the variables to be merged with the main document is the _____. C. Shows suggested revisions in a document. D. A keyboard search uses ________________ to match keywords. E. Contains the text and graphics that remain the same for each version of the merged document. F. Inserted as placeholders at the place where the name, address, and other data will appear in a form letter. G. All the variables for one individual are called a(n) ______. H. A resume in a Word document attached to an e-mail is an example of a(n) ____________.

Computer Science & Information Technology