1. What is the syntax to inherit from a class in C#?
Place a colon & then the name of the base class.
Example: class MyNewClass : MyBaseClass
2. Can you prevent your class from being inherited by another class?
Yes. The keyword “sealed” will prevent the class from being inherited.
3. Can you allow a class to be inherited, but prevent the method from being over-ridden?
Yes. Just leave the class public and make the method sealed.
4. What’s an abstract class?
A class that can not be instantiated. An abstract class is a class that must be inherited and have the methods to replace. An abstract class is essentially a project for a class without any implementatio.
5. When do you absolutely have to declare a class as abstract?
1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.
2. When at least four of the methods in the class is abstract.
6. What is an interface class?
Interfaces, like classes, define a set of properties, methods and events. But unlike classes, interfaces do not provide the application. They are implemented by classes, and defined as separate entities from classes.
1 comments: