A1:
| A sealed class cannot be inherited. A sealed class is used primarily when the class contains static members. Note that a struct is implicitly sealed. |
A2:
| A class can inherit from one class explicitly and inherits from System.Object implicitly. It can inherit from any number of interfaces. |
A3:
|
ShowName is static and cannot be referenced from a class instance.
ShowName.ShowMe("My Name is Ishmael");
|
A4:
| An abstract class may contain both abstract and non-abstract methods. |
A5:
| new is used to replace (not override) an inherited method with one of the same name. |
A6:
| (a) x=60 y=40. x is passed by reference; y by value. |
A7:
| Include a method that performs the same operation as the operator overloading. |
A8:
| A class cannot be instantiated if it is abstract or if it has a private constructor. |
A9:
| Example event handler:
private void PrintSale(object sender, SaleEvArgs e)
{
decimal prc= (decimal)e.saleprice;
DateTime dt = (DateTime)e.date;
int itemNum = (int)e.itemnum;
// Now print the values
}
|
A10:
| (a) Compilation error indicating that keyword new is required on Child.amethod(int, string) because it hides the inherited method. If new is used, the code prints "Base Constructor". |