C# Interview Questions
C# Interview Questions
C# Interview Questions for Freshers
What is C# ?
C# is a type-safe, managed and object oriented language, which is compiled by .Net framework for generating intermediate language (IL).
What are features of C# ?
- Constructors and Destructors
- Properties
- Passing Parameters
- Arrays
- Main
- XML Documentation and
- Indexers
Give Advantage of C# ?
- Easy to learn
- Object oriented
- Component oriented
- Part of .NET framework
Types of comments in C# ?
There are three type of comments are supported by C#. They are given below;
- Single Line Comment Eg : //
- Multiline Comments Eg: /* */
- XML Comments Eg : ///
What is sealed class in C# ?
Sealed class is used to prevent the class from being inherited from other classes. So sealed modifier also can be used with methods to avoid the methods to override in the child classes.
Differences between Array and ArrayList in C# ?
Array stores the values or elements of same data type but arraylist stores values of different datatypes.
Arrays will use the fixed length but arraylist does not uses fixed length like array.
Explain namespaces in C# ?
Namespaces are containers for the classes. We will use namespaces for grouping the related classes in C#.
Give reason behind the invention of C# ?
It is designed for Common Language Infrastructure (CLI). It contains the executable code and runtime environment that makes the users able to use various high-level languages on different computer platforms and architectures.
Why use C# ?
Some reason behind using C# is given below.
- Onject oriented programming language
- General purpose programming language
- Component oriented
- It is part of .net framework
- Produces efficient programs
- Structured language
- You can compiled any platform
What is void is C# ?
Void is a type modifier that specifies that the method doesn't return any value.
What is public in C# ?
You can access public declared variables anywhere in the application.
What is static in C# ?
For access static variable no need to create instance of variable. Static declared variables are globally accessible.
What are constructors in C# ?
Constructor is special member function of class which have same name as class name. Whenever object is created constructor will call automatically.
Different types of constructors in C# ?
Generally five types of constructor available in C# those are given below;
- Static constructor
- Private constructor
- Copy constructor
- Default constructor
- Parameterized constructor
What is Garbage Collection ?
Garbage Collection is a process of releasing or make free memory automatically occupied by objects which are no longer accessible.
What is delegate in C# ?
Delegate in C# is an object that holds the reference to a method. It is same like function pointer in C++.
What is array in C# ?
Array is the collection of similar data type. In C# Array is a set of related instances either value or reference types.
What is method overloading in C# ?
.Method overloading means multiple methods available with same name and unique signature in same class.
Is overriding of a function possible in the same class ?
No, overriding is achieve at base class and derived class level.
Types of array in C# ?
There are three types of array supported by C#, which are given below;
- Single Dimensional Array
- Multi Dimensional Array
- Jagged Array
What is Hashtable ?
A Hashtable is a combination of key/value pairs. It contains values based on the key.
What is boxing in C# ?
When a value type is converted to object type, it is called boxing.
What is the purpose of using statement in C# ?
using keyword is used to include a namespace in the program.