Sponsored Ad

Sunday, January 3, 2010

C# Class Questions

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:

  1. Hi , Rahul I just look at your posts and I can said You are very active blogger :) that's very good.
    You write useful post good work and all the best in 2010 ;) Nezir
    ReplyDelete

Sponsored Ad

More Related Articles

Website Update

Followers