Object-Oriented Programming - .NET Interview Questions and Answers
What are collections and generics?
A collection can be defined as a group of related items that can be referred to as a single unit. The System.Collections namespace provides you with many classes and interfaces. Some of them are - ArrayList, List, Stack, ICollection, IEnumerable, and IDictionary. Generics provide the type-safety to your class at the compile time. While creating a data structure, you never need to specify the data type at the time of declaration. The System.Collections.Generic namespace contains all the generic collections.
How can you prevent your class to be inherited further?
You can prevent a class from being inherited further by defining it with the sealed keyword.
What is the index value of the first element in an array?
In an array, the index value of the first element is 0 (zero).
Can you specify the accessibility modifier for methods inside the interface?
All the methods inside an interface are always public, by default. You cannot specify any other access modifier for them.
Is it possible for a class to inherit the constructor of its base class?
No, a class cannot inherit the constructor of its base class.
How is method overriding different from method overloading?
Overriding involves the creation of two or more methods with the same name and same signature in different classes (one of them should be parent class and other should be child).
Overloading is a concept of using a method at different places with same name and different signatures within the same class.