C# interview Question And Answer 2020 - part 1

Category > CSHARP || Published on : Wednesday, November 11, 2020 || Views: 625 || C# interview Question And Answer 2020 - part 1


1) What’s the advantage of using System.Text.StringBuilder over System.String?
Strings are object which cannot be modified once created. Each time when the string is operated an instance for the object is created. String builder is more efficient then the system.string while manipulating on string.

2) Can you store multiple data in System.Array?
Using System.Array to store multiple data types is not possible. In case if the user is willing to store in multiple data types they can make use of array list.

3) What’s a delegate?
A delegate is a type-safe object which can point to another method or multiple methods in the application.
A delegate consist of
Method name
Argument (if any)
Return value (if any)

4) What is hashtable?
Hashtable is a .NET datatype that helps in retrieval of data using a unique key.

5) Can multiple catch blocks be executed?
It is not possible to execute multiple catch block. Since once the catch code fires the controlled is automatically pass to the final code and the final code starts execution.

6) What are advantages of Microsoft-provided data provider classes in ADO.NET?
It is able to handle single tier to multi-tier.
Provides data security.
They perform task faster.

7) What is an interface class?
Interface class specify the methods, properties and events but they don’t provide implementation as like classes. The implementation is done by the class and are defined as separate entity from classes.

8) Can you inherit multiple interfaces?
Multiple interface cannot be implemented using .NET. since .NET doesn’t support interface.

9) What is an abstract class?
Abstract class is a class that cannot be instantiated. It is a class to be inherited and the methods to be overridden.

10) What’s a multicast delegate?
A delegate that has multiple handlers assigned to it. Each assigned handler (method) is called.

11) What does the term immutable mean?
Immutable refers to data values which cannot be changed.

12) What is difference between of the C and C#?
C is not case sensitive but C# is sensitive.
C# focus more on design and C is on function.
C# is object oriented and C is structured language.
C# is type safe but C is not.

13) What is the difference between C# and java?
Java is cross platform language and C# is window specific language.
C# relies on windows system foundation whereas java rely on java virtual machine.
JVM converts byte code into executable code. C# converts into MSIL.

14) What is the syntax to inherit from a class in C#?
Class newclass: baseclass
Class can be inherited by placing the class name after the colon.

15) What is Microsoft.Access?
Microsoft.Access is used to connect to database inorder to access them.

16) How to Do File Exception Handling in C#?
Exception handling is a built in mechanism in .NET framework. It enables to identify errors and to handle run time errors. They contain lot of standard exception.

17) What’s the difference between // comments, /* */ comments and /// comments?
// comment is used to said single comment.
/* */ Comment is used for multiple line comment.
/// comment is for XML documentation comment.

18) How can you sort the elements of the array in descending order?
Sorting the elements in the descending order can be done by the function sort() and the reverse() method.

19) How’s the DLL Hell problem solved in .NET?
Assembly versioning specify the library that required by the application to run and also the version of the library to the application.

20) What is the use of serializable keyword in C#?
Declaring a class with the keyword serializable enables the object to be serialized mainly for exchange of data between two system. If the object going to inherit by any other object then serialization downstream required to be used.

21) Pointers in c#?
C# supports pointers but it required to be specified within the unsafe code.
For example
Unsafe
{
// usage of pointers
}

22) How does C# implement events?
C# implements events by the following:-
Pointers
Delegates
DLLs

23) What does assert() do?
Assert taken the parameter in Boolean condition, while debugging it shows the error dialog when the condition fails. If the condition true the program proceeds without any interruption.

23) What is the name of C#.NET compiler?
C#.NET compiler is JIT(Just in time) compiler.

24) What is true about readonly variable in C# code?
Read only file is to be initialized at the time of the construction of the object.

25) What is shadowing?
Shadowing is a VB.NET concept which can implement base class without overriding the members of the class. Any class member can be shadowed by using the keyword SHADOW.

 

Web Development Interview Questions
Database Interview Questions
Mobile Development Interview Questions
Others Interview Questions