C Sharp Interview Questions and Answers - 4

Question: 16

What is an ArrayList?

The ArrayList object is a collection of items containing a single data type values.

Question: 17

What is Enums in C#?

Enums or Enumerators are used to declare a set of related constants (default start with 0); they are only available with primitive data types like int and short etc.

Question: 18

What do you mean by boxing and un-boxing?

C# provides us with Value types and Reference Types. Value Types are stored on the stack and Reference types are stored on the heap. The conversion of value type to reference type is known as boxing and converting reference type back to the value type is known as un-boxing.
e.g.
int x = 10;
object o = x ; // Implicit boxing
object o = (object) x; // Explicit Boxing
x = o; // Implicit Un-Boxing
x = (int)o; // Explicit Un-Boxing

Question: 19

What is a Static class? What are its features?

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

Important Features:

Static class only contains static members and a private constructor.

Static class cannot be instantiated.

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

Question: 20

What is sealed class? What are its features?

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.

Related Questions