C# Interview Questions with answers

Q1.  What is C#?

Ans:  C# (is pronounced as "C sharp") is a simple, modern, object-oriented, and type-safe programming language.It combines the high productivity of Rapid Application Development (RAD) languages.

Q2.  Explain a DataSet?

Ans: It is an in memory representation of data loaded from any data source.


Q3.  Explain Constructors?

Ans:  It is called constructor because it constructs the values of data members of the class.It is a member function with the same name as its class. It is invoked whenever an object of its associated class is created.

Q4.  What is object?

Ans:  It is an instance of a class. It is created by using operator new. A class that creates an object in memory will contain the information about the values and behaviours of that specific object.

Q5.  Explain interface class?

Ans:  It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes.

Q6.  What is ENUM?

Ans:  It is used to define constants.

Q7.  What does Dispose method do with connection object ?

Ans:  Deletes it from the memory.

Q8.  Explain difference between Class And Interface?

Ans:  It is collection of data and related sub procedures with defination.Class is a logical representation of object.
Interface is also a class containg methods which is not having any definations.Class does not support multiple inheritance while interface can support.

Q9.  Explain the role of the DataReader class in ADO.NET connections?

Ans:  It returns a read-only dataset from the data source when the command is executed.

Q10.  Is it possible to change the value of a variable while debugging a C# application?

Ans:  Yes, if we are debugging via Visual Studio.NET, just go to Immediate window.

Q11.  Explain the difference between the Debug class and Trace class?

Ans:  Debug class is used for debug builds and Trace class is used for both debug and release builds.

Q12.  How can we sort the elements of the array in descending order?

Ans:  By calling Sort() and then Reverse() methods.

Q13.  Are private class-level variables can inherited?

Ans:  Yes, but they are not accessible, so we can say that they are not inherited. But they are.

Q14.  Explain the types of comment in C#?

Ans:  Types of comments in C#.
•    Single line (//)
•    Multi (/* */)
•    Page/XML Comments (///).

Q15.  Explain difference between // comments, /* */ comments and /// comments?

Ans:  Single-line, multi-line and XML documentation comments.

Q16.  Is it possible to declare the override method static while the original method is non-static?

Ans:  No, we can not do so, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.

Q17.  What does the This window show in the debugger?

Ans:  It shows the object that’s pointed to by this reference. Object’s instance data is shown.

Q18.  What are the different namespaces used in C#.NET?

Ans:  Namespace used in C#.NET are
•    using System;
•    using System.Collections.Generic;
•    using System.Windows.Forms;

Q19.  Explain the types of access modifiers in C#?

Ans:  Access modifiers in C# are :
•    public
•    protect
•    private
•    internal
•    internal protect

Q20.  What are three services model (three-tier application).

Ans: 
Presentation (UI)
Business (logic and underlying code)
Data (from storage or other sources).

Q21.  Can we override private virtual methods?

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

Q22.  Explain an abstract base class?

Ans:  It is a class that is designed to be specifically used as a base class. An abstract class contains at least one pure virtual function.

Q23.   Why can’t we specify the accessibility modifier for methods inside the interface?

Ans:  They all must be public. So, for preventing us from getting the false impression that we have any freedom of choice, we are not allowed to specify any accessibility, it’s public by default

Q24.  Explain polymorphism?

Ans:  Polymorphism means multiple forms but one name. It allows us to have more than one function with the same name in a program.It allows us to have overloading of operators so that an operation can exhibit different behaviours in different instances.

Q25.  Is it possible to store multiple data types in System.Array?

Ans:   No.

Q26.  Explain multicast delegate?

Ans:  It’s a delegate that points to and eventually fires off several methods.

Q27.  Explain difference between the System.Array.CopyTo() and System.Array.Clone()?

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

Q28.  Explain the use of using statement in C#?

Ans:  This statement is used to obtain a resource, execute a statement, and then dispose of that resource.

Q29.  Explain the role of the DataReader class in ADO.NET connections?

Ans:  It returns a read-only dataset from the data source when the command is executed.

Q30.  Explain the difference between Structure and Class?

Ans: Difference between Structure and Class are
•    Structures are value type and Classes are reference type
•    Structures can not have contractors or destructors.
•    Classes can have both contractors and destructors.
•    Structures do not support Inheritance, while Classes support Inheritance.

Q31.  Explain the pre-requisite for connection pooling?

Ans:  Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings.

Q32.  Explain the types of arrays in C#?

Ans:
•    Single-Dimensional
•    Multidimensional
•    Jagged arrays.

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Best Hostgator Coupon Code