Organizational Research By

Surprising Reserch Topic

Question:C# Interview questions?


1. What is Overriding?
Overriding is a concept where a method in a derived class uses the same name with the same return type and also the same arguments as a method in its base class. In other words, if the derived class contains its own implementation of the method rather than using the method in the base class, the process is called overriding
2.What are events and delegates?
An event is a message sent by a control to notify the occurrence of an action. However it is not known which object receives the event. For this reason, .NET provides a special type called Delegate which acts as an intermediary between the sender object and receiver object
3.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.
4.difference between public, static and void?
All these are access modifiers in C#. Public declared variables or methods are accessible anywhere in the application. Static declared variables or methods are globally accessible without creating an instance of the class. The compiler stores the address of the method as the entry point and uses this information to begin execution before any objects are created. And Void is a type modifier that states that the method or variable does not return any value.
5.difference between ref & out parameters?
An argument passed as ref must be initialized before passing to the method whereas out parameter needs not to be initialized before passing to a method
6. Can “this” be used within a static method? 
We can’t use ‘This’ in a static method because we can only use static variables/methods in a static method.
7.What is difference between constants and read-only? 
Constant variables are declared and initialized at compile time. The value can’t be changed after wards. Read-only variables will be initialized only from the Static constructor of the class. Read only is used only when we want to assign the value at run time.
8. What is an interface class? 
Interface is an abstract class which has only public abstract methods and the methods only have the declaration and not the definition. These abstract methods must be implemented in the inherited classes.
9. What are value types and reference types? 
Value types are stored in the Stack whereas reference types stored on heap.
Following are some of the Value types:
int, enum , byte, decimal, double, float, long 
Reference Types:
string , class, interface, object.
10. Different categories of inheritance?
There are 4 types of Inheritance in Object Oriented Programming and they are as follows
(i)Single inheritance : Have one base class and one derived class.
(ii)Hierarchical inheritance : Have one base class and multiple derived classes of the same base class.
(iii)Multilevel inheritance : Have a class derived from a derived class.
(iv)Multiple inheritance : Have several base classes and a derived class.
11. Difference between constants, readonly and, static ?
(i) Constants: Value can’t be changed.
(ii) Read-only: Value will be initialized only once from the constructor of the class.
(iii)Static: Value can be initialized once.
12. What is multi cast delegates?
Each delegate object holds reference to a single method. However, it is possible for a delegate object to hold references of and invoke multiple methods. Such delegate objects are called multicast delegates or combinable delegates.
13.What is data encapsulation?
Data encapsulation, also referred to as data hiding, is the mechanism whereby the implementation details of a class are kept hidden from the user. The user can only perform a restricted set of operations on the hidden members of the class by executing special functions called methods.
14.Is it possible to override private virtual methods? 
No. Private methods are not accessible outside the class.
15.Can you store multiple data types in System.Array? 
16. What’s the difference between the System.Array.CopyTo() and System.Array.Clone()? 
The first one performs a deep copy of the array, the second one is shallow.

asked Sep 13, 2013 in Csharpenet by anonymous
edited Sep 12, 2013
0 votes

Related Hot Questions

1 Answer

0 votes


1. How do you generate documentation from the C# file commented properly with a command-line compiler? Compile it with a /doc switch. 
2. What's the difference between and XML documentation tag? Single line code example and multiple-line code example. 
3. Is XML case-sensitive? Yes, so and are different elements. 
4. What debugging tools come with the .NET SDK? CorDBG – command-line debugger, and DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch. 
5. What does the This window show in the debugger? It points to the object that's pointed to by this reference. Object's instance data is shown. 
6. What does assert() do? In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true. 
7. What's the difference between the Debug class and Trace class? Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds. 
8. Why are there five tracing levels in System.Diagnostics.TraceSwitcher? The tracing dumps can be quite verbose and for some applications that are constantly running you run the risk of overloading the machine and the hard drive there. Five levels range from None to Verbose, allowing to fine-tune the tracing activities. 
9. Where is the output of TextWriterTraceListener redirected? To the Console or a text file depending on the parameter passed to the constructor. 
10. How do you debug an ASP.NET Web application? Attach the aspnet_wp.exe process to the DbgClr debugger. 
11. What are three test cases you should go through in unit testing? Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly). 
12. Can you change the value of a variable while debugging a C# application? Yes, if you are debugging via Visual Studio.NET, just go to Immediate window. 
13. Explain the three services model (three-tier application). Presentation (UI), business (logic and underlying code) and data (from storage or other sources). 
14. What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET? SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but it's a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines. 
15. What's the role of the DataReader class in ADO.NET connections? It returns a read-only dataset from the data source when the command is executed. 
16. What is the wildcard character in SQL? Let's say you want to query database with LIKE for all employees whose name starts with La. The wildcard character is %, the proper query with LIKE would involve 'La%'. 
17. Explain ACID rule of thumb for transactions. Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no "in-between" case where something has been updated and something hasn't), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after). 
18. What connections does Microsoft SQL Server support? Windows Authentication (via Active Directory) and SQL Server authentication (via Microsoft SQL Server username and passwords). 
19. Which one is trusted and which one is untrusted? Windows Authentication is trusted because the username and password are checked with the Active Directory, the SQL Server authentication is untrusted, since SQL Server is the only verifier participating in the transaction. 
20. Why would you use untrusted verificaion? Web Services might use it, as well as non-Windows applications. 
21. What does the parameter Initial Catalog define inside Connection String? The database name to connect to. 
22. What's the data provider name to connect to Access database? Microsoft.Access. 
23. What does Dispose method do with the connection object? Deletes it from the memory. 
24. What is a pre-requisite for connection pooling? Multiple processes must agree that they will share the same connection, where every parameter is the same, including the security settings.
answered Sep 13, 2013 by rajesh
edited Sep 12, 2013