.NET - Object-Oriented Programming
5.
Explain the basic features of OOPs.
The following are the four basic features of OOP:
- Abstraction - Refers to the process of exposing only the relevant and essential data to the users without showing unnecessary information.
- Polymorphism - Allows you to use an entity in multiple forms.
- Encapsulation - Prevents the data from unwanted access by binding of code and data in a single unit called object.
- Inheritance - Promotes the reusability of code and eliminates the use of redundant code. It is the property through which a child class obtains all the features defined in its parent class. When a class inherits the common properties of another class, the class inheriting the properties is called a derived class and the class that allows inheritance of its common properties is called a base class.
6.
What is the difference between arrays and collection?
Array:
Collection:
- You need to specify the size of an array at the time of its declaration. It cannot be resized dynamically.
- The members of an array should be of the same data type.
Collection:
- The size of a collection can be adjusted dynamically, as per the user's requirement. It does not have fixed size.
- Collection can have elements of different types.
7.
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.
8.
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.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers