C#.NET Interview Questions And answers for Experienced

Question.1   What are implementation inheritance and interface inheritance?

Answer:    Implementation inheritance is achieved when a class is derived from another class in such a way that it inherits all its members. Interface inheritance is when a class inherits only the signatures of the functions from another class.

Question.2  What are generics in C#.NET?

Answer:     Generic types to maximize code reuse, type safety, and performance. They can be used to create collection classes. Generic collection classes in the System.Collections.Generic namespace should be used instead of classes such as ArrayList in the System.Collections namespace. [sociallocker]

Question.3   What is the use of GetCommandLineArgs() method in C#.NET?

Answer:     With GetCommandLineArgs() method, the command line arguments can be accessed. The value returned is an array of strings.

Question.4   What is the use of System.Environment class in C#.NET?

Answer:    The System.Environment class can be used to retrieve information like command-line arguments, the exit code, environment variable settings, contents of the call stack, time since last system boot, the version of the common language runtime.

Question.5   What is an Exception in .NET?

Answer:   Exceptions are errors that occur during the runtime of a program. The advantage of using exceptions is that the program doesn’t terminate due to the occurrence of the exception. Whenever an exception is occurred the .NET runtime throws an object of specified type of Exception. The class ‘Exception’ is the base class of all the exceptions..

Question.6   What are Custom Exceptions?

Answer:   Custom Exceptions are user defined exceptions.

Question.7   What is a Constructor?

Answer:   It is the first method that are called on instantiation of a type. It provides way to set default values for data before the object is available for use. Performs other necessary functions before the object is available for use.

Question.8  Can private virtual methods be overridden in C#.NET?

Answer:    No, moreover, you cannot access private methods in inherited classes. They have to be protected in the base class to allow any sort of access.

Question.9  Is is possible to force garbage collector to run?

Answer:  Yes, we can force garbage collector to run using System.GC.Collect().

Question.10   What is an Event?

Answer:    When an action is performed, this action is noticed by the computer application based on which the output is displayed. These actions are called events. Examples of events are pressing of the keys on the keyboard, clicking of the mouse. Likewise, there are a number of events which capture your actions.

Question.11   What is Delegate?

Answer:   Delegates are kind of similar to the function pointers. But they are secure and type-safe. A delegate instance encapsulates a static or an instance method. Declaring a delegate defines a reference type which can be used to encapsulate a method having a specific signature.

Question.12   How does object pooling and connection pooling differ?

Answer:    In Object pooling, you can control the number of connections. In connection pooling, you can control the maximum number reached. When using connection pooling, if there is nothing in the pool, a connection is created since the creation is on the same thread. In object pooling, the pool decides the creation of an object depending on whether the maximum is reached which in case if it is, the next available object is returned. However, this could increase the time complexity if the object is heavy.

Question.13  What is Language Integrated Query (LINQ)?

Answer:   LINQ is a set of extensions to .NET Framework that encapsulate language integrated query, set and other transformation operations. It extends VB, C# with their language syntax for queries. It also provides class libraries which allow a developer to take advantages of these features.

Question.14   Explain the purpose of CultureInfo class. What namespace contains it?

Answer:    System.Globalization namespace contains CultureInfo class. This class provides information about a specific culture, i.e. datetime format, currency, language etc.

Question.15   Which is the class from where everything is derived in .NET?

Answer:  System.Object. Object class is the ultimate base class of all classes in the .NET Framework, it is the root of the type hierarchy. It is often used as a generic argument in class methods – all classes are treatable as Object classes.

Question.16   What is the use of assert() method?

Answer:   Assert method is in debug compilation. It takes a boolean condition as a parameter. It shows error dialog if the condition is false and if the condition is true, the program proceeds without interruption.

Question.17   Difference between the System.Array.CopyTo() and System.Array.Clone()?

Answer:   System.Array.CopyTo() performs a deep copy of the array. System.Array.Clone() performs a shallow copy of the array

Question.18  What is the purpose of Dispose method?

Answer:  Dispose method is used to destroy the objects from the memory.

Question.19  What is the difference between shadow and override?

Answer:  In general when you extend a class you shadow fields with the same name in the base class and override virtual methods with the same name and parameter list in the base class. Overriding makes the base class method invisible. Shadowing a field only hides the field from view. You can still explicitly touch the hidden shadowed field if you wish. You cannot touch an invisible overridden method.[/sociallocker]

Learn C# NET Online Course By Expert