11 Basic Interview Questions : c# and OOPs (Basics)
Being a fresher or experienced professional with maybe 6 years or even 10 years of experience, its rightly said you need to keep your fundamentals and building blocks strong and clear!

Every company in this dense IT world web has different products or projects that they deal in. So, many times you might find companies with same model and concept but I am sure still if you dig down the project you will end up witnessing 2 completely different projects in terms of code written, the pattern followed, the terminology used, folder structure maintained or even the way of writing code. Now, in such a scenario when companies feel more requirement for IT professionals, They go through the process of judging the basic skills of the person. As it is quite obvious that work and knowledge of the project/product that person will work on will be delivered to him/her once he/she is recruited and assigned to the work.
So, To all the people trying to look out for jobs or their “dream job”, I have listed below few of the most commonly asked questions based on basics of the concept which might seem very easy and that you have heard or used zillion times but what matters is the correct way of portraying it and explaining it in front of the interviewer.
Ques 1 : What is Object Oriented Programming?
Answer 1: As simple as name says, Programming that revolves around “OBJECTS”. It aims to implementing real-world entities like inheritance, hiding, polymorphism etc in programming. Few of the major concepts in OOPs are — “Object”, “Method”, “Class”, “Abstraction”, “Encapsulation”, “Polymorphism”, “Inheritance”.

Ques 2 : Why Object Oriented Programming?
Answer 2 : Another important question that comes right after first question is WHY? What makes OOP Better? WHY OOP?

Going down to the lane, Object-oriented programming has several advantages:
- Provides a clear structure for the programs
- Code Reuse and Recycling makes an important factor.
- Makes it possible to create full reusable applications with less code and shorter development time
- Helps to keep the C++ code DRY “Don’t Repeat Yourself”, and makes the code easier to maintain, modify and debug
- Implementation details are hidden from other modules
- Real life application Solving
- Good for defining abstract data types.
- Faster and easier to execute
Ques 3 : What is inheritance?
Answer 3: Inheritance is one of the most important and core pillar of object-oriented programming. It derives a class from another class for a hierarchy of classes that share a set of attributes and methods. A class derived from another class is called a subclass, whereas the class from which a subclass is derived is called a superclass. Primarily used for reuse code from an existing class. C# offers quite different forms of inheritances. One example of inheritance is explained below. In below example, we have a base class which has two properties and two methods to set the values in those properties. Now we create a new class that will act as a derived class as we are inheriting base class “Dimension”. In this case, properties and methods of a base class are now available to the derived class as well.

Ques 4 : Is Multiple inheritance possible?
Answer 4: In c# NO. A very simple example to just describe the problem is “Too Much of the Complexity and Confusion.”
For example, if Class C inherits from both Class A and Class B, suppose both define a property named attr1 and a function named getAttr1(). Then, which copy will ‘C’ get or will it get two copies, one from each parent? This conflict can be resolved by a few approaches but they are not proper ways to achieve this. Hence, to lower down this confusion C# doesn't allow Multiple Inheritance.

Ques 5 : Explain the difference between PUBLIC, STATIC and VOID?
Answer 5 :
public − This is the access specifier that states that the method or attribute can be accessed as a public attribute i.e. can be used publicly.
static − Static means that class doesn’t require to be instantiated. Static Class can only have static members.
void − This states that the method doesn’t return any value.
Ques 6 : what is an interface?
Answer 6: An Interface is a type definition in c#. It can only contain abstract methods and properties. You can declare your properties, methods in Interface, further when a class implements this interface it can define the functionalities of the method accordingly. A simple example is attached below, where we define an interface named IPlant, that has few properties and a method, please note we have clearly just declared the method not defined it. Not all the classes implementing IPlant will have to specify the define method HasFragrance(). If you have noticed interface doesn’t have access specifiers. As we can’t define access specifiers in Interface. Another important thing is the class that implements an interface will have to surely define all the methods.

Ques 7 : What are sealed class in c#?
Answer 7: What if, a user wants to restrict a class from being inherited? Define it as a sealed class. You can define a class as sealed by simply adding the sealed keyword in front of the class declaration.

Ques 8 : what is method overloading?
Answer 8: Method overloading is a form of polymorphism in c#. It allows you to redefine a function in different forms. Overloaded methods have the same name but different signatures, they may differ in terms of parameters, count of parameters, types of parameters etc. Method overloading is one of the ways by which C# achieve Compile Time Polymorphism(Static Polymorphism). Method overloading can be done by changing :
- The number of parameters in two methods.
- The data types of the parameters of methods.
- The Order of the parameters of methods.

Ques 9 : What is method overriding?
Answer 9: Method overriding is another form of polymorphism. Method Overriding allows accessing functions from another class (base class) in the derived class. Creating a method in the derived class with the same declaration or signature as a method in the base class is called method overriding. Method overriding is one of the ways by which C# achieve Run Time Polymorphism(Dynamic Polymorphism).

Ques 10 : What is exception handling in c#?
Answer 10: An exception is an unwanted or unexpected hindrance in the program’s execution during run time. These exceptions need to be handled properly for the proper flow of the program. C# provides built-in support to handle the exception using try, catch & finally block.

**A Detailed Post on Exception handling will be coming up Next.**
Ques 11 : List down the types of exceptions in c#?
Answer 11 :

Topics discussed above in the form of important questions are quite vast and elaborated topics. This post focus on their brief introduction and overview. I will try my best to get back to the readers with elaborated posts soon to go and read in-depth about a few of the topics mentioned above.
Thank you so much for your time.
