C# Interview Questions and Answers Part 12

1. What is a class?

Ans. Class is concrete representation of an entity. It represents a group of objects, which hold similar attributes and behavior. It provides Abstraction and Encapsulations.

2. What is a Static class? What are its features?

Ans. Static class is a class which can be used or accessed without creating an instance of the class.

Important Features:

1. Static class only contains static members and a private constructor.

2. Static class cannot be instantiated.

3. Static classes are sealed by default and therefore cannot be inherited.

3. What is sealed class? What are its features?

Ans. Sealed classes are those classes which can not be inherited and thus any sealed class member can not be derived in any other class. A sealed class cannot also be an abstract class.

In C# structs are implicitly sealed; therefore, they cannot be inherited.

4. What is an Object? What is Object Oriented Programming?

Ans. Object represents/resembles a Physical/real entity. An object is simply something you can give a name. Object

Oriented Programming is a Style of programming that represents a program as a system of objects and enables


5. What is Encapsulation?

Ans. Encapsulation is binding of attributes and behaviors. Hiding the actual implementation and exposing the

functionality of any object. Encapsulation is the first step towards OOPS, is the procedure of covering up of data

and functions into a single unit (called class). Its main aim is to protect the data from out side world.

6. What is Abstraction?

Ans. Hiding the complexity. It is a process of defining communication interface for the functionality and hiding rest of the things.

7. What is Overloading?

Ans. Adding a new method with the same name in same/derived class but with different number/types of parameters. It implements Polymorphism.

8. What is Overloading?

Ans. A process of creating different implementation of a method having a same name as base class, in a derived class. It implements Inheritance.

9. What is Shadowing?

Ans. When the method is defined as Final/sealed in base class and not override able and we need to provide different implementation for the same. This process is known as shadowing, uses shadows/new keyword.

10. What is a life span of a static variable?

Ans. A static variable’s life span is till the class is in memory.


Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker