List of top 10 most asked c# interview questions. Make sure you prepare these while going for an interview.
Top 10 C# Interview Questions
1. What is C#?
C# is an object oriented, type safe and managed language that is compiled by .Net framework to generate Microsoft Intermediate Language.
2. Benefits of using C#
These are the top benefits of using C# language:
- Easy to learn
- General purpose and object oriented programming language
- Component oriented
- Structured language
- Can be compiled on variety of computer platforms
- Produces efficient programs
- Part of .net framework
3. What is the difference between public, static and void?
Public declared variables can be accessed anywhere in the application.
Static declared variables are globally accessible without creating an instance of the class. Static member are by default not globally accessible it depends upon the type of access modified used.
Void is a type modifier that states that the method or variable does not return any value.
4. Can multiple catch blocks be executed?
No, Multiple catch blocks can’t be executed. Once the proper catch code executed, the control is transferred to the finally block and then the code that follows the finally block gets executed.
5. Write down the different types of constructors in C#?
Basically, there are five types of constructors used in C#.
- Static constructor
- Private constructor
- Copy constructor
- Default constructor
- Parameterized constructor
6. Pillars of OOP in C#?
Abstraction is the process of exposing few features of an entity.
Encapsulation is a way of restricting access to certain properties or component.
Inheritence is ‘is are‘ relationship. The base class has properties and methods that will be inherited by the sub class.
Polymorphism is the ability to redefine methods for derived class.
7. Explain overloading and overriding?
Overloading means we will declare methods with same name with different parameters. It’s compile time method.
Overriding means we will declare methods with the same name and same parameters. We can override a method in base class by creating similar function in derived class by using virtual & override keyword. It’s run time method.
8. Is overriding of a function possible in the same class?
No, it’s not possible to override in the same class.
9. What are the different types of array supported by C#?
There are three types of array supported by C#
- Single Dimensional Array: It contains a single row. It is also known as vector array.
- Multi Dimensional Array: It is rectangular and contains rows and columns.
- Jagged Array: It also contains rows and columns but it has an irregular shape.
10. What is the difference between ref & out parameters?
When an argument is passed as ref, it must be initialized before passing to the method whereas out parameter needs not to be initialized before passing to a method.
Hope these top 10 c# interview questions will make your interview super good. Please do not live on only these questions. Keep preparing for everything else too.