Random .NET Interview Questions

Back to Notes on .NET

C# General Interview Questions

C# Questions on properties, events etc

Questions on XML, ADO.NET etc

C# Rapid Fire Questions 1

C# Rapid Fire Questions 2

SQL Interview Questions 1

SQL Interview Questions 2

Random .NET Questions

Download Ebooks


















































Q. What is Dipose method?

Dispose is the method, which we call usually when we want the object to be garbage collected. If u r calling Dispose() on inbuilt classes like Form, It'll call a method Finalize() method, which will usually used to cleanup any resources used with in the form. With in this Finalize method, we call the garbage collector to recycle the memory. So, when u r using dispose method, it is used to mark the object to Garbage Collectable. Calling the Dispose ose't means, that object will be garbage collected immediately. GC will monitor the Managed memory for objects Marked 4 garbage collectable. The recycling of memory depends on when the GC will pay the visit. Purely the Dispose method is not used for reseting the values in the object. It is used to mark the Object to b collected by the GC


Q. When can all the session state data be retrieved. Choices are:

1) during init
2) during prerender
3) during load event..
Ans. Page init event will occur, when the request will b handled
by the worker process on server. Page_init is the first event which will instantiate the page. Here itself u can get the session state data if it is the first time request to the server. The pre-render is the one of the stage in the page life cycle where the page content will be converted to the browser specific. The server can get the information about the browser which made the request. Rendering means placing the controls on the browser. Page_Pre-render event will fire just before the page_render event. B4 the page render page load event fire.

Q. How many types of JIT compilers are available?

Ans. There are Two types of JIT compilers.
Standard JIT compiler.
Econo JIT compiler.

Q. What are the different types of assemblies – name them?
Satellite assembly

Q. What is GAC? What are the steps to be taken to pick up the latest version from GAC?
This Global Assembly Cache(GAC) stores .NET assemblies to be shared by several applications on that computer.
Publisher policy file is the configuration file to redirect to different
1. Create the publisher Policy assembly using the assembly linker
2. Add the publisher policy assembly to the GAC using GACutil tool
Gacutil /i
3. During runtime CLR is looking into the publisher policy file and
redirect the application to bind with new version assembly as specified inside the publisher policy.

Q. How do we use different versions of private assemblies in same application without re-build?
In Asseblyinfo file, we need to specify assembly version.
assembly: AssemblyVersion

Q. Different methods of using a legacy COM component in .NET framework?
1. Use TLBIMP to create an Assembly from a COM component
2. Reference a COM component directly from .NET Editor

Q. How do you implement SSL?

1. create certificate request
=>Right click on the website (VD)
=>Click Directory Security Tab and click Server Certificate
=> Type name of certificate , Organization name , server name
location info,
=> Type the path need to save certificate information Submit
certificate request.

2.Submit Certificate request.
=> Browse http://WebServerName/CertSrv/
=> select Request a Certificate and click Next
=> select Advanced Request and click Next
=> select Submit a Certificate Request using a Base64 and
click Next
=> open the request document "Create a certificate request"
=> Copy the contents of the document
=> Paste the contents of the document into the Web form's
Base64 Encoded Certificate Request text box
=> Under Certificate Template, select Web Server or User, and
then click Submit

Q. Is it possible to debug java-script in .NET IDE? If yes, how?
Yes. Write debugger statement to stop the cursor for debugging .

Q. How do you create a webservice proxy without .NET IDE and how do you test it?
Using WSDL utility we can test by consuming our service either windows / web application

Q. How to debug an assembly which is on Server?
[assembly: AssemblyDescription("Debug")]

Q. How many ways can we maintain the state of a page?
1.Client Side [ Query string, hidden variables, view state,cookies]
2.Server side [application , session, database]

Q. How do we Generate and compile source code dynamically?
.Net provides powerful access to the IL code generation process
through the System.CodeDom.Compiler and Microsoft.CSharp and Microsoft.VisualBasic namespaces. In these namespaces we can find the tools that allow us to compile an assembly either to disk or into memory. We can also need the Reflection namespace as it contains the tools to invoke an object and its methods once we have compiled the object.

Q. How to pass server control values from one form to another using in-line code?

Q. How to make a webservice call asynchronous?

//Create a new instance of the Web Service Class
localhost.Service1 service = new MyWebServiceApp.localhost.Service1();
//Make the asynchronous Web Service call and call WriteHello
service.BeginHelloWorld(new System.AsyncCallback (WriteHello), service);

private void WriteHello(System.IAsyncResult oRes)
//End the call
localhost.Service1 service = (MyWebServiceApp.localhost.Service1)

//Write the call result to a MessageBox

Q. How to invoke a webservice using javascript?

<script language ="javascript">
Function init()
Service.useservice("/services/test.asmx?WSDL", "MyTest");
Var iCallID;
iCallID = service.MyTest.callService("add",1,2);

<body onload ="init()">
<div id ="test" style ="behaviour:url(webservice.htc)"></div>

Q. List out all the possible ways of maintaining the state of a session.
InProc, OutProc [State server, sql]

Q. What is the use of multicast delegate?
A multicast delegate can call more than one method.

Q. What is the purpose of a private constructor?
Prevent the creation of instance for a class

Q. Differentiate Dispose and Finalize.
Finalize is called by the Garbage Collector, and the state of
manage objects cannot be guaranteed, so we can not reference them. Also, we cannot determine when the GC will run, and which objects it will Finalize. Dispose is called by the programmer, and is used to dispose of managed and unmanaged objects. Within we dispose method, we release all of our resources and call GC.SuppressFinalize as we have done the work of the GC.

Q. What is the purpose of Singleton pattern?
Singleton pattern is used to make sure that only one
instance of a given class exists.

Q. Difference between structure and class.
Structures are value types;
Classes are reference types.

Structures use stack allocation; classes use heap allocation.
All structure elements are Public by default; class variables and constants are Private by default, while other
class members are Public by default.

Structure elements cannot be declared as Protected;
Class members can.

Structure variable declarations cannot specify initializers or initial
sizes for arrays; class variable declarations can.

Structures implicitly inherit from the System.ValueType class and
cannot inherit from any other type; classes can inherit from any class or classes other than System.ValueType.

Structures are not inheritable; classes are.

Structures are never terminated, so the common language runtime

(CLR) never calls the Finalize method on any structure; classes are terminated by the garbage collector (GC), which calls Finalize on a class when it detects there are no active references remaining.

Q. Difference between DOM and SAX parser.

DOM Approach is useful for small documents in which the program
needs to process a large portion of the document.
SAX approach is useful for large documents in which the program
only needs to process a small portion of the document
SAX parsers generally requires more code than the DOM interface.
Unless we build a DOM style tree from our application's internal
representation for the data, we can't as easily write the XML file back to disk.
The DOM tree is not constructed, so there are potentially less
memory allocation. If we convert the data in the DOM tree to another format, the SAX API may help to remove the intermediate step If we do not need all the XML data in memory, the SAX API allows us to process the data as it is parsed.

Q. Under what circumstances do you use DOM parser and SAX parser
DOM Approach is useful for small documents in which the program needs to process a large portion of the document.

SAX approach is useful for large documents in which the program only
needs to process a small portion of the document
If we do not need all the XML data in memory, the SAX API allows us
to process the data as it is parsed.

Q. What is a well-formed XML and is the purpose of Diffgram?
Textual object is a well-formed XML document if it satisfies all the
following points
1. Taken as a whole, it matches the production labeled document.
2. It meets all the well-formedness constraints given in this specification.
3. Each of the parsed entities which is referenced directly or indirectly
within the document is well-formed.
The purpose of Diffgram is the Ability to pass parameters. It contains the tags that specify the original and new state of data

Q. Differentiate between legacy ADO recordset and .NET dataset.
What are typed datasets?

Ans. Recordset provides data one row at a time.
Connection is open.
Dataset is a data structure which represents the complete table data
at same time. Dataset is just a data store and manipulation is done through

DataAdapters in .NET
Typed DataSets generate classes that expose each object the in the

DataSet in Type-safe manner. It will raise error at compile time if any mismatch of column data type.