.NET Framework Interview Questions Answers by tallboy20045

VIEWS: 586 PAGES: 49

More Info
									1 What are Web services?
Web services are functions exposed by server­side applications. They are programmable units that other applications (and Web services) can access over the Internet.
More details can be found at:
http://www.roseindia.net/webservices/webservices.shtml
http://www.webopedia.com/TERM/W/Web_services.html

2 What are session management techniques in .NET?
There are three different techniques of managing session in ASP.NET
InProc
Session state is stored locally in memory of ASP.NET worker process.
StateServer
Session state is stored outside ASP.NET worker process and is managed by Windows service. Location of this service is specified by stateConnectionString attribute.
SQLServer
Session state is stored outside ASP.NET worker process in SQL Server database. Location of this database is represented by sqlConnectionString attribute.
For more details, please visit
http://shailkpatel.blogspot.com/2007/03/session­management­techniques.html895r

3 What is MVC (Model View Controller) pattern?
The Model­View­Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes
[Burbeck92]:
Model. The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds
to instructions to change state (usually from the controller).
View. The view manages the display of information.
Controller. The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.
For more details and its implementaion, please see
http://www.c­sharpcorner.com/UploadFile/napanchal/MVCDesign12052005035152AM/MVCDesign.aspx
http://msdn2.microsoft.com/en­us/library/ms978748.aspx
http://msdn2.microsoft.com/en­us/library/ms998540.aspx

4 How to use trace in libraray classes (like BAL, DAL)?
Use following code to use Trace.Warn, Trace.Write etc.
System.Web.HttpContext.Current.Trace

5 What is gacutil.exe?
It's a command to install the assembly into the Global Assembly Cache.

6 What is boxing and unboxing?
Converting a value type to reference type is called Boxing and Converting reference type of value type is Unboxing.
int i = 1;
object o = i; // boxing
int j = (int) o; // unboxing

7 What provider ADO.NET use by default?
   1.   SqlClient
   2.   Oledb
   3.   Odbc
   4.   Oracle

Correct Ans : 1 ADO.NET is optimized for SQL Server database so it by use System.Data.SqlClient provider.

8 Difference between Response.Expires and Response.ExpiresAbsolute?
Response.Expires
This property specifies the number of minutes before a page cached in the browser expires ie. if the user returns to the same page before the specified number of
minutes the cached version of the page is displayed.

Response.ExpiresAbsolute
Using this property we can set the date and/or time at which page cached in the browser expires.

9 What is CLR (Common Language Runtime)?
This is an execution engine for .NET Framework application. It provides a number of services including
1. Code Management
2. Application memory isolation
3. Verification of type safety
4. Conversion of IL to native code.
5. Access to meta data
6. Managing memory for managed objects
7. Enforcement of code access security
8. Exception handling, including cross­language exceptions.
9. Inter operation between managed code, COM objects and pre­existing DLLs (Unmanaged code and data)
10. Automation of object layout
11. Support for developer services (profiling, debugging etc.)

10 Write a function into Javascript that will toggle display a HTML element.

function ShowHide(id)
              {
document.getElementById(id).style.display == '' ? document.getElementById(id).style.display = 'none' : document.getElementBy
              }



We can call this function like
<a href="#" onclick="ShowHide('divid')">Show/Hide</a>
If the "divid" is already displaying on the page it will hide if not it will show on the page and so on.

11 When to use String and StringBuilder class?
Use the String class to concat, join or format methods to join multiple items in a single statement.
Use StringBuilder class to create dynamic strings.

12 Which statement is correct in terms of try catch finally block?



                                                                                                                                                        Page 1 of 49
   1.   try catch finally
   2.   try catch catch finally
   3.   try finally
   4.   try catch catch catch finally

Correct Ans : All above four are correct. We can keep try catch finally or there can be more than one catch block with different exceptions. If we are implementing the
error handling/catching error mecahnism in calling function we can write simple try finally block without write catch block,

13 String is a value type or reference type?
String is a reference type variable.

14 List few ValueTypes variables.
Below are all ValueTypes variables.
System.SByte,
System.Byte
System.Int16
System.Int32
System.Int64
System.Single
System.Double
System.Decimal
System.Char
System.Boolean
System.DateTime

15 What is the use of RCW & CCW?
RCW : Runtime Collable Wrapper takes a COM component, wrap it up and allows .NET client to consume it.
CCW: COM Collable Wrapper wraps a .NET object for consumption by COM client

16 What is StringCollection?
StringCollection is a simple resizable collection of strings
Following function shows how to insert and retrive data into/from StringCollection.


public static string GetStringCollection()
              {
                     System.Text.StringBuilder strB = new System.Text.StringBuilder();
                     // Add strings into StringCollection
                     System.Collections.Specialized.StringCollection strC = new System.Collections.Specialized.StringCollection();
                     strC.Add("Ram 1");
                     strC.Add("Ram 2");
                     strC.Add("Ram 3");
                     strC.Add("Ram 4");
                     strC.Add("Ram 5");


                     // Retrieve string from StringCollection
                     System.Collections.Specialized.StringEnumerator coll = strC.GetEnumerator();
                     while (coll.MoveNext())
                     {
                           strB.Append(coll.Current + "
");
                     }
                     return strB.ToString();
              }


17 Where reference and value types variables are stored?
All reference type variables are stored in heap (Random) and all value types variables are stored in stack (Sequential).

18 What is Singleton pattern?
Singleton pattern ensures a class has only one instance & provide a global point of access to it. It is achieved by declaring a static variable for the class & checking for null
before actually instantiating it.

19 What does apsx stand for?
Active Server Pages Extension

20 What is CTS?
CTS (Common Type System) is a rich type system, build into the common language runtime that supports the types and operations found in most of the programming
languages. The common type system supports the complete implementation of a wide range of programming language.

21 What is CLS?
CLS (Common Language Specification) is a set of constructs or constraints that serves as a guide for library writers and compiler writers.It allows libraries to be fully
usable from any language supporting the CLS, and for those languages to integrate with each other. The CLS is a subset of common type system. The common language
specifications is also important to application developers wh are writing code that will be used by other developers.

22 What is MSIL?
MSIL (Microsoft Intermediate Language) is a CPU­Independent instructions set into which .NET Framework programs are compiled. It contains instructions for loading,
storing, initializing and calling methods on objects.

23 What is Satellite Assembly?
It is a often used to deploy language specific resources for an application. These assemblies work in side­by­side execution because the application has a separate
product ID for each language & installed satellite assemblies in a language specific sub­directory.
When uninstalling, the application removes only the satellite assemblies associated within a give language & .NET Framework version.

24 What is RSS?
RSS (Really Simple Syndication/Rich Site Summary) is a light weight XML format for distributing news headlines or site summary & other contents of the website.

25 What is application domain?
The primary purpose of application domain is to isolate an application from other application. Win32 process provides isolation but in distinct memory address spaces.
This is effective but it is expensive and doesn't scale well. The .NET runtime enforces app domain isolation by keeping control over the use of memory.




                                                                                                                                                               Page 2 of 49
All memory in the app domain is managed by the .net runtime so the runtime can ensure that app domain do not access each other's memory. Objects in different
application domains communicate either by transporting copies of objects across application domain boundries or by using a proxy to exchange messages.

26 What is Remoting in .NET?
.NET Remoting offers much more complex functionality including support for passing objects by values or by references, callbacks & multiple objects activation ^ life
cycle management policy.
In order to use Remoting a client need to build using .NET.

27 What is Property?
A property is a method or pair of methods that are exposed to the outside world as if they are fields.

28 Can you assign GridView.DataSource = DataReader()?
   1.   Yes
   2.   No
   3.   It will not only work for Web based
   4.   It will bind some records only

Correct Ans : 1 This will work for both web and windows based application.

29 Can a DataAdapter.Fill method take DataTable as parameter or it works only for DataSet?
It has 5 different overloads and of course it can take DataSet as well as DataTable as parameter to fill data in from database.

30 What is typed dataset ?
A typed dataset is very much similar to a normal dataset. But the only difference is that the sehema is already present for the same. Hence any mismatch in the column
will generate compile time errors rather than runtime error as in the case of normal dataset. Also accessing the column value is much easier than the normal dataset as
the column definition will be available in the schema.

31 Can you place two .dll files with the same name in GAC (Global Assembly Cache)?
Yes, provided both have different versions.
GAC is a Folder that contains .dll that have strong name. So we can keep myproject.dll and myproject.dll two files into GAC with different version like 1.0.0.0 and 1.0.0.1

32 What's the difference between private and shared assembly?
Private Assembly is used inside an application only and does not have to be identified by a strong name.
Shared Assembly can be used by multiple applications and has to have a strong name.

33 What is the location of Global Assembly Cache on the system.
C:\$WINDOWS\assembly

34 What is JIT (Just­in­time) Compiler ?
Just­in­time compiler is a compiler used to convert the Commmon Intermediate Language (CIL) code into native code (also called machine code) that is processed by
machine.
A little description
While compiling of .NET program, its code is converted into Common Intermediate Language code that is done by Common Language Runtime.

But while executing the program this CIL code is converted into Machine code or Native code that is done by JIT Compiler.

35 What is Managed and Unmanaged code?
Managed Code is what Visual Basic .NET and C# compilers create. It compiles to Intermediate Language (IL), not to machine code that could run directly on your
computer. The IL is kept in a file called an assembly, along with metadata that describes the classes, methods, and attributes (such as security requirements) of the code
you've created. This assembly is the one­stop­shopping unit of deployment in the .NET world. You copy it to another server to deploy the assembly there—and often
that copying is the only step required in the deployment.
Unmanaged code is what you use to make before Visual Studio .NET 2002 was released. Visual Basic 6, Visual C++ 6, heck, even that 15­year old C compiler you may still
have kicking around on your hard drive all produced unmanaged code. It compiled directly to machine code that ran on the machine where you compiled it—and on
other machines as long as they had the same chip, or nearly the same. It didn't get services such as security or memory management from an invisible runtime; it got
them from the operating system. And importantly, it got them from the operating system explicitly, by asking for them, usually by calling an API provided in the Windows
SDK. More recent unmanaged applications got operating system services through COM calls.
For more, see http://www.codeguru.com/columns/Kate/article.php/c4871/

36 What is the difference between Namespace and Assembly?
Namespace:
1. It is a Collection of names wherein each name is Unique.
2. They form the logical boundary for a Group of classes.
3. Namespace must be specified in Project­Properties.
Assembly:
1. It is an Output Unit. It is a unit of Deployment & a unit of versioning. Assemblies contain MSIL code.
2. Assemblies are Self­Describing. [e.g. metadata,manifest]
3. An assembly is the primary building block of a .NET Framework application. It is a collection of functionality that is built, versioned, and deployed as a single
implementation unit (as one or more files). All managed types and resources are marked either as accessible only within their implementation unit, or by code outside
that unit.

37 What is Manifest?
The manifest describes the assembly, providing the logical attributes shared by all the modules and all components in the assembly. The manifest contains the assembly
name, version number, locale and an optional strong name that uniquely identifying the assembly.

38 What is Metadata?
Metadata is the complete way of describing what is in a .NET assembly. Digging into the metadata yields the types available in that assembly, viz. classes, interfaces,
enums, structs, etc., and their containing namespaces, the name of each type, its visibility/scope, its base class, the interfaces it implemented, its methods and their
scope, and each method’s parameters, type’s properties, and so on.

39 What is CODE Access security?
Code Access Security (CAS), in the Microsoft .NET framework, is Microsoft's solution to prevent untrusted code from performing privileged actions.
It performs following function
1. Defines permissions and permission sets that represent the right to access various system resources.
2. Enables administrators to configure security policy by associating sets of permissions with groups of code (code groups).
3. Enables code to request the permissions it requires in order to run, as well as the permissions that would be useful to have, and specifies which permissions the code
must never have.
4. Grants permissions to each assembly that is loaded, based on the permissions requested by the code and on the operations permitted by security policy.
5. Enables code to demand that its callers have specific permissions.
6. Enables code to demand that its callers possess a digital signature, thus allowing only callers from a particular organization or site to call the protected code.
7. Enforces restrictions on code at run time by comparing the granted permissions of every caller on the call stack to the permissions that callers must have.

40 What’s difference between System.SystemException and System.ApplicationException?
The difference between ApplicationException and SystemException is that SystemExceptions are thrown by the CLR, and ApplicationExceptions are thrown by
Applications.

41 What is multi­threading?




                                                                                                                                                           Page 3 of 49
It is basically trying to do more than one thing at a time within a process.
There are two main ways of multi­threading which .NET encourages: starting your own threads with ThreadStart delegates, and using the ThreadPool class either directly
(using ThreadPool.QueueUserWorkItem) or indirectly using asynchronous methods (such as Stream.BeginRead, or calling BeginInvoke on any delegate).

42 Which namespace threading contains?
   1.   System.Threading
   2.   System.Machine.Theading
   3.   System.Thread.Threading
   4.   System.DotNetThreading

Correct Ans : 1 The System.Threading namespace provides classes and interfaces that enable multithreaded programming. In addition to classes for synchronizing thread
activities and access to data ( Mutex, Monitor, Interlocked, AutoResetEvent, and so on), this namespace includes a ThreadPool class that allows you to use a pool of
system­supplied threads, and a Timer class that executes callback methods on thread pool threads.

43 What the way to stop a long running thread ?
System.Threading.Thread.Abort

44 What is the diffeernce between Overload and Override?
Overload is the another version of the same function into the class. There can be different parameters, return type in overload functions (in brief: Same function and
different parameters).
Override is entirely overriding the base class function and creating our own version in the child class. Base class and child class function name and return type should be
same.

45 How many web.configs can an application have?
Moderated by Webmaster
Original answer:
There can only be 1 web.config in an application.
Corrected answer:
An application can have multiple web.config files but in different directories ... mean each and every directory can have a web.config file. For little more, visit
http://www.dotnetfunda.com/questions/question137.aspx

46 Where do you store connection string?
Database connection string can be stored in the web config file.

47 What is abstract class
Abstract class cannot be instantiated instead it has to be inherited. The methods in abstract class can be overridetn in the child class

48 What are the collection classes?
The .NET Framework provides specialized classes for data storage and retrieval.

49 list the object­oriented concepts
Inheritance
Abstraction
Polymorphism
Encapsulation

50 What is difference between interface inhertance and class inheritance?
If its a interface inheritance and the inheritad class is not a abstact class or a interface class then all the methods in the supper class needs to be implemented.
Class inheritance no need such thing.

51 What are Abstract base classes?
Abstact Class is nothing but a true virtual class..
This class cannot be instantiated instead it has to be inherited.
The method in abstract class are virtual and hence they can be overriden in the child class.

52 When is web.config called?
Web.config is an xml configuration file. It is never directly called unless we need to retrieve a configurations setting.

53 What does connection string consist of?
Server, user id, password, database name.

54 What is a runtime host?
The runtime host is the environment in which the CLR is started and managed.

55 What inheritance does VB.NET support?
Single inheritance using classes or multiple inheritance using interfaces.

56 Differences between application and session ?
The application level variable hold value at the application level and their instances are destroyed when the no more client access that application, whereas session
correspond to a individual user accessing the application.

57 What is web application virtual directory
Virtual directory is the physical location of the application on the machine.
By default it’s ­ inetpub/wwwroot

58 If cookies is disabled in client browser, will session tracking work?
No, maintaining value in cookie wont be possible. In that case you have to make use of other ways to maintain state of the data on page.
you can check whether client support cookies or not by using
Request.Browser.Cookies property.

59 What is a Process, Session and Cookie?
Process ­ Instance of the application
Session ­ Instance of the user accessing the application
Cookie ­ Used for storing small amount of data on client machine.

60 Explain serialization?
Serialization is a process of converting an object into a stream of bytes.
.Net has 2 serializers namely XMLSerializer and SOAP/BINARY Serializer.
Serialization is maily used in the concept of .Net Remoting.

61 What is the difference between overloading and overriding ? how can this be .NET?
Overriding ­ Method has the same signature as the parent class method.
Overloading ­ Method having diff parameters list or type or the return type may be different.

62 Explain friend and protected friend?
Friend/Internal ­ Method, Properties in that class can be accessed by all the classes within that particular assembly.
Protected Friend/Protected Internal ­ Methods, Properties can be accessed by the child classes of that particular class in that particular assembly.

63 What is isPostback property?
. This property is used to check whether the page is being loaded and accessed for the first time or whether the page is loaded in response to the client postback.
Example:
Consider two combo boxes



                                                                                                                                                              Page 4 of 49
In one lets have a list of countries
In the other, the states.
Upon selection of the first, the subsequent one should be populated in accordance. So this requires postback property in combo boxes to be true.

64 Can you give an example of when it would be appropriate to use a web service as opposed to a non­serviced .NET component?
When to use Web Service:
1. Communicating through a Firewall When building a distributed application with 100s/1000s of users spread over multiple locations, there is always the problem of 
communicating between client and server because of firewalls and proxy servers. Exposing your middle tier components as Web Services and invoking the directly from 
a Windows UI is a very valid option. 
2. Application Integration When integrating applications written in various languages and running on disparate systems. Or even applications running on the same 
platform that have been written by separate vendors. 
3. Business­to­Business Integration This is an enabler for B2B intergtation which allows one to expose vital business processes to authorized supplier and customers. An 
example would be exposing electronic ordering and invoicing, allowing customers to send you purchase orders and suppliers to send you invoices electronically. 
4. Software Reuse This takes place at multiple levels. Code Reuse at the Source code level or binary componet­based resuse. The limiting factor here is that you can 
reuse the code but not the data behind it. Webservice overcome this limitation. A scenario could be when you are building an app that aggregates the functionality of 
serveral other Applicatons. Each of these functions could be performed by individual apps, but there is value in perhaps combining the the multiple apps to present a 
unifiend view in a Portal or Intranet. 
When not to use Web Services:
1. Single machine Applicatons When the apps are running on the same machine and need to communicate with each other use a native API. You also have the options of 
using component technologies such as COM or .NET Componets as there is very little overhead. 
2. Homogeneous Applications on a LAN If you have Win32 or Winforms apps that want to communicate to their server counterpart. It is much more efficient to use 
DCOM in the case of Win32 apps and .NET Remoting in the case of .NET Apps

65 How to retrieve the last error occured in the application?
Use Server.GetLastError();

66 How to clear the last error occured in the application?
Use Server.ClearError();

67 when we do the searchpattern in Directory.GetFiles(DirectoryPath, Filter) it will show the 5.docx files two times.
this is the bug of 
Directory.GetFiles
it only match for 3 no of character of extention.
show when we filter for doc then it also include the docx file/

68 Whats MSIL, and why should my developers need an appreciation of it if at all?
MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL. MSIL also allows the .NET Framework to JIT compile the 
assembly on the installed computer.

69 Can I use the Win32 API from a .NET Framework program?
Yes. Using platform invoke, .NET Framework programs can access native code libraries by means of static DLL entry points. 
Here is an example of C# calling the Win32 MessageBox function: 
using System; 
using System.Runtime.InteropServices; 
class MainApp 
{ 
[DllImport("user32.dll", EntryPoint="MessageBox")] 
public static extern int MessageBox(int hWnd, String strMessage, String strCaption, uint uiType); 
public static void Main() 
{ 
MessageBox( 0, "Hello, this is PInvoke in operation!", ".NET", 0 ); 
} 
}

70 What are Dead letter queues?
The main use of queue is that you do not need the client and the server running at one
time. So it’s possible that a message will lie in queue for long time until the server or client
picks it up. But there are scenarios where a message is of no use after a certain time. So
these kinds of messages if not delivered within that time span it should not be sent to the
user.
Below is the config snippet which defines for how much time the message should be in
queue.
<bindings>
<netMsmqBinding>
<binding name="MyBindings"
deadLetterQueue="Custom"
customDeadLetterQueue="net.msmq://localhost/private/
ServiceModelSamples"
timeToLive="00:00:02"/>
</netMsmqBinding>

71 what are the various ways of hosting a WCF service?
There are three major ways to host a WCF service:­
1. Self hosting the service in his own application domain. This we have already covered
in the first section. The service comes in to existence when you create the object of
ServiceHost class and the service closes when you call the Close of the ServiceHost
class.
2. Host in application domain or process provided by IIS Server.
3. Host in Application domain and process provided by WAS (Windows Activation
Service) Server.

72 can we force garbage collector to run?
System.GC.Collect() forces garbage collector to run.This is not recommended but can be used if situation arises.

73 What is the difference between debug build and release build?
The biggest difference between these is that:
In a debug build the complete symbolic debug information is emitted to help while debugging applications and also the code optimization is not taken into account.
While in release build the symbolic debug info is not emitted and the code execution is optimized.
Also, because the symbolic info is not emitted in a release build, the size of the final executable is lesser than a debug executable.
One can expect to see funny errors in release builds due to compiler optimizations or differences in memory layout or initialization. These are ususally referred to as 
Release ­ Only bugs :)
In terms of execution speed, a release executable will execute faster for sure, but not always will this different be significant.

74 Difference between String and Stringbuilder reference types?
System.string provides a set of members for working with text.Like search,replace,concratinate etc.. and strings of type system.string are immutable(that means any 
change to string causes a runtime to create a new string and abandon old one).
System.stringbuilder is used to dynamic strings which are mutable also.these string classes also overrides operators from System.object.




                                                                                                                                                           Page 5 of 49
75 How do you configure the SOAP (Simple Object Access Protocol) to associate with particular web method?
   1.   Add <SoapExtension> element in web.config file and set the method attribute to be the name of your web method.
   2.   . Add <SoapExtensionMethod> element to the web.config file that is set to the name of your web method.
   3.   Add a class to your extension that that inherits from the System.Web.Services.Protocols.SoapExtensionAttribute class.
   4.   Add a class to your extension that inherits from the System.Web.Services.Protocols class.

Correct Ans : 3

76 Your Web site processes book orders. One of the application methods contains the following code segment.XmlDocument doc = newXmlDocument();doc.LoadXml
(“<book><discount>10</discount>”+”<title>Dictionary</title></book>”);You need to remove the discount element from XmlDocument. Which two code segments
can you use to achieve this goal?
   1.   XmlNode root = doc.DocumentElement;root.RemoveChild(root.FirstChild);
   2.   XmlNode root = dec.DocumentElement;root.RemoveChild(root.SelectSingleNode(“discount”));
   3.   doc.RemoveChild(doc.FirstChild);
   4.   doc.DocumentElement.RemoveChild(doc.FirstChild);

Correct Ans : 1 Correct Answer : Answer 1 & Answer 2

77 Garbage Collection (GC) is a one of the data structure collection in .NET Framework. While creating Web Service through visual studio template, which
namespaces are include automatically?
   1.   System.Web
   2.   System.WebServices
   3.   System.Web.Services
   4.   System.Web.Services.Protocols

Correct Ans : 1 Corret Answer is : 1 & 3 & 4 Description: ­­“System.Web” Used to enable client­to­server communication. ­­“System.Web.Services” includes
“WebService” and “WebMethod” attribute class.­­“System.Web.Services.Protocols” contains the classes needed to transmit XML.

78 What is the primary purpose of Namespace property, which is used in WebServices attribute?
   1.   . To set XML namespace to SOAP message to distinguish your web services from other web services
   2.   Reference to company’s website
   3.   Reference to the organization which set the standards related to web services
   4.   Documentation related to web services

Correct Ans : 1

79 Which page is used to display the link of webmethods in ASP.NET web services?
   1.   ASP.NET services method web page.
   2.   ASP.NET services help page.
   3.   ASP.NET webmethod help page
   4.   All of the above

Correct Ans : 2

80 What are the three main section of SOAP (Simple Object Access Protocol) message?
   1.   SOAP message formatted with SOAP 1.1 specification might contains a Header, Action and Body element.
   2.   SOAP message formatted with SOAP 1.1 or SOAP 1.2 specification might contains a Header, Action and Body element.
   3.   SOAP message formatted with SOAP 1.1 specification might contains Envelope, Header, and Body element.
   4.   SOAP message formatted with SOAP 1.1 or SOAP 1.2 specification might contains Envelope, Header, and Body element.

Correct Ans : 4 SOAP (Simple Object Access Protocol) message formatted with the 1.1 or 1.2 specification might contain an Envelope, Header and Body Element. Header
Element is optional.

81 For SOAP (Simple Object Access Protocol) message formatting what is the purpose of Encoded value?
   1.   Encoded value ensures that SOAP message is encrypted for security perpose.
   2.   Encoded value ensures that the SOAP message will be formatted as XML schema definition in the WSDL.
   3.   This is the default value for parameter encoding
   4.   is the default value for parameter encapsulation.

Correct Ans : 2 Encoding value is used to indicate a specific formatting schema.

82 Which method is used to serialize an object into an XML document from Xmlserializer class?
   1.   ToSerial
   2.   Deserialize
   3.   Serialize
   4.   Xmlserialize

Correct Ans : 2 The Serialize method is the first step of serialize process and used to create an XML document

83 What value can be used when setting the direction of the SOAP header?
   1.   In, Out
   2.   In, Out, InOut, Fault
   3.   In, Out, InOut
   4.   In, Out, InOut, NoFault

Correct Ans : 2

84 Which is a true statement for BeforeSerialize stage of an in­coming request message occurs?
   1.   Occurs right after the web method is invoked but before the request is serialized into XML
   2.   Occurs before response is de­serialized into an object.
   3.   Occurs after serialization but before XML is sent across the network.
   4.   Right after the de­serialization process but before the client receives the result.

Correct Ans : 1

85 What is true for namespace in .NET Framework?
   1. Namespace is a logically group types.
   2. An assembly can contain any number of Namespace.




                                                                                                                                                     Page 6 of 49
   3. Same namespace can exist in different assemblies.

Correct Ans :

86 What is Manifest?
   1.   In .NET Framework Assembly metadata stored in Manifest.
   2.   In .NET Framework Namespace metadata stored in Manifest.
   3.   NET Framework use Manifest to stored only Assemblies version.
   4.   None of these

Correct Ans : 1 Manifest contains all the metadata needed to do the following things 1. Version of assemblies 2. Scope of assemblies. 3. Reference to resource and class
4. Assemblies manifest stored in Portable Executable (PE) file or in Microsoft Intermediate Language (MSIL) code.

87 whats the similarilty & difference between .dll extension and .exe extension files?
A standard exe application is one that is created using Standard EXE project. It is the most widely used Project type using VB6. Standard EXE application is normally the
most widely used among the available Project types in Visual Basic. Stand­alone programs have an .EXE file extension.
Usage A standard EXE application is normally used when you want to develop a stand­alone application. Examples include calculators, text editors, and other similar
applications.
An ActiveX EXE application is one that is created using ActiveX EXE project. ActiveX EXE are widely used in conjunction with standard EXE applications. There are three
types of widely used of ActiveX projects. These are:
a. ActiveX EXE
b. ActiveX DLL
c. ActiveX Control
ActiveX EXE: Unlike a stand­alone EXE file, an ActiveX EXE file is designed to work as an OLE server, which is nothing more than a program designed to share information
with another program. It has an .EXE file extension.
ActiveX DLL: ActiveX DLL files are not meant to be used by themselves. Instead, these types of files contain subprograms designed to function as building blocks when
creating a stand­alone program. It has a .DLL file extension.
ActiveX Control: Unlike an ActiveX DLL or ActiveX EXE file, an ActiveX Control file usually provides both subprograms and a user interface that you can reuse in other
programs. It has an .OCX file extension.
Usage
1. The ActiveX EXE/DLL is normally used when you need to build a component that is separate from the main program. The concept is based on COM model.
2. ActiveX DLL/EXE allows multiple applications to share the same code. This allows for scalability of programs, and saves time because you only need to write the code
once.
3. ActiveX DLLs and ActiveX EXEs are almost same in the ways they are built and used. In either case, you build one or more classes that applications can use to do
something.
4. One of the main differences between ActiveX EXE and an ActiveX DLL's is that the code is executed within the main program's address space for ActiveX DLL. This is
because the code lies inside the program's address space, calling methods and execution of code is very fast.
Differences
An ActiveX Exe provides the reusability of code, by accessing it from different clients.
An ActiveX Exe is a component that can be called by another application by providing a reference to the component. But a Standard Exe application cannot be called in
this way.
An ActiveX EXE's code is run in a separate process. When the main program calls an ActiveX EXE's method, the application passes required parameters into the ActiveX
EXE's and calls the method. The ActiveX EXE, upon execution may return the results to the main program. This is slower than running an ActiveX DLL's method inside the
main program's address space.

88 If I write System.exit (0); at the end of the try block, will the finally block still execute ?
No in this case the finally block will not execute because when you say System.exit (0); the control immediately goes out of the program, and thus finally never executes.

89 What is the difference between Master­ Detail view and MVG?
Following are the main advantages:­
1) MVG Makes effective use of the space.
2) Multiple set of detail records can be viewed from a single
view

90 Difference between VB.NET and C#.
Difference between VB.NET and C#.
VB.NET :
­­­­­­­­­­­
1)no unsigned int
2)Loosely typed language
3)no operator overloading
4)no pointers
5)no auto XML documentation

C#.net :
­­­­­­­­­­­­­
1) supports unsigned int
2)strongly typed language
3)supports operator overloading
4)supports pointers
5)supports auto XML documentation

91 Name a feature which is common to all .NET languages?
Name a feature which is common to all .NET languages?
There is only one feature which is common to all languages and that is Garbage collection or GC. This feature is automated which relieves developers of much work. This
garbage is disposed only when there is need of memory or stress for memory. GC feature halts the application for few seconds before restarting it.

92 Most Important Questions in Interview
Q1. Explain the differences between Server­side and Client­side code?
Ans. Server side code will execute at server (where the website is hosted) end, & all the business logic will execute at server end where as client side code will execute at
client side (usually written in javascript, vbscript, jscript) at browser end.
Q2. What type of code (server or client) is found in a Code­Behind class? Ans. Server side code.
Q3. How to make sure that value is entered in an asp:Textbox control? Ans. Use a RequiredFieldValidator control.
Q4. Which property of a validation control is used to associate it with a server control on that page? Ans. ControlToValidate property.
Q5. How would you implement inheritance using VB.NET & C#? Ans. C# Derived Class : Baseclass
VB.NEt : Derived Class Inherits Baseclass
Q6. Which method is invoked on the DataAdapter control to load the generated dataset with data? Ans. Fill() method.




                                                                                                                                                            Page 7 of 49
Q7. What method is used to explicitly kill a user's session? Ans. Session.Abandon()
Q8. What property within the asp:gridview control is changed to bind columns manually? Ans. Autogenerated columns is set to false
Q9. Which method is used to redirect the user to another page without performing a round trip to the client?
Ans. Server.Transfer method.
Q10. How do we use different versions of private assemblies in same application without re­build? Ans.Inside the Assemblyinfo.cs or Assemblyinfo.vb file, we need to
specify assembly version.
assembly: AssemblyVersion

93 What event can you subscribe to if you want to display information from SQL Print statements?
   1.   InfoMessage
   2.   MessageReceived
   3.   PostedMessage
   4.   NewInfo

Correct Ans : 1

94 Advantages of Crystal Reports
Advantages of Crystal Reports
Some of the major advantages of using Crystal Reports are:
1. Rapid report development since the designer interface would ease the coding work for the programmer.
2. Can extend it to complicated reports with interactive charts and enhance the understanding of the business model
3. Exposes a report object model, can interact with other controls on the ASP.NET Web form
4. Can programmatically export the reports into widely used formats like .pdf, .doc, .xls, .html and .rtf

95 What is the Difference between Web.config and Machine.config?
Scope:
Web.config => For particular application in IIS.
Machine.config = > For All the applications in IIS
Created:
Web.config => Created when you create an application
Machine.config => Create when you install Visual Studio
Known as:
Web.config => is known as Application Level configuration file
Machine.config => is known as Machine level configuration file
Location:
Web.config => In your application Directory
Machine.config => …\Microsoft.NET\Framework\(Version)\ CONFIG

96 What’s the difference between Response.Write() andResponse.Output.Write()?
Response.Output.Write() allows you to write formatted output.

97 From the following which datatype is not supported in RangeValidator?
   1.   Integer
   2.   String
   3.   Date
   4.   Long

Correct Ans : 4

98 What is the Global.asax used for?
The Global.asax (including the Global.asax.cs file) is used to implement application and session level events.

99 What does the "EnableViewState" property do? Why would I want it on or off?
It allows the page to save the users input on a form across postbacks. It saves the server­side values for a given control into ViewState, which is stored as a hidden value
on the page before sending the page to the clients browser. When the page is posted back to the server the server control is recreated with the state stored in
viewstate.

100 What is GC in NET Framework?
The .NET Framework's garbage collector manages the allocation and release of memory for your application. Each time you use the new operator to create an object,
the runtime allocates memory for the object from the managed heap. As long as address space is available in the managed heap, the runtime continues to allocate space
for new objects. However, memory is not infinite. Eventually the garbage collector must perform a collection in order to free some memory. The garbage collector's
optimizing engine determines the best time to perform a collection, based upon the allocations being made. When the garbage collector performs a collection, it checks
for objects in the managed heap that are no longer being used by the application and performs the necessary operations to reclaim their memory.

101 What is the common language runtime (CLR)?
The common language runtime (CLR) is major component in the .NET Framework and it is the execution engine for .NET Framework applications.
It is responsible for proving the number of services, including the following:
1. Code management (loading and execution)
2. Verification of type safety
3. Conversion of Microsoft Intermediate Language (MSIL) to native code
4. Access to metadata (enhanced type information)
5. Managing memory for managed objects
6. Enforcement of code access security (See what is code access security?)
7. Exception handling, including cross­language exceptions
8. Interoperation between managed code, COM objects, and pre­existing DLLs (unmanaged code and data)
9. Automation of object layout
10. Support for developer services (profiling, debugging, and so on)

102 What is the common type system (CTS)?
The common type system (CTS) is a rich type system, built into the common language runtime (CLR) that supports the types and operations found in most of .NET
programming languages. The common type system supports the complete implementation of a wide range of programming languages.

103 What is the Microsoft Intermediate Language (MSIL)?
MSIL is the Machine independent Code into which .NET Framework programs are compiled. It contains instructions for loading, storing, initializing, and calling methods
on objects. Combined with metadata and the common type system, MSIL allows for true cross language integration. Prior to execution, MSIL is converted to machine
code via CLR’s Just­in­Time (JIT) compiler.




                                                                                                                                                            Page 8 of 49
104 What is managed code and managed data?
We can describe this Manage code like, if a code running under the control CLR, then we can call it as Managed Code.
Managed code is code that is written to target the services of the common language runtime (see what is CLR?). In order to target these services, the code must provide
a minimum level of information (metadata) to the runtime. All C# (when not using the unsafe keyword), Visual Basic .NET, J#, and JScript .NET code is managed by
default. Visual Studio .NET C++ code is not managed by default, but the compiler can produce managed code by specifying a Command­line switch (/CLR). Closely related
to managed code is managed data—data that is allocated and reallocated by the common language runtime's garbage collector. C#, Visual Basic.NET, J# and JScript .NET
data is managed by default. C# data can, however, be marked as unmanaged through the use of special keywords. Visual Studio .NET C++ data is unmanaged by default
(even when using the /CLR switch), but when using Managed Extensions for C++, a class can be marked as managed by using the __gc keyword. As the name suggests,
this means that the memory for instances of the class is managed by the garbage collector. In addition, the class becomes a full participating member of the .NET
Framework community, with all of the benefits and restrictions that brings. An example of a benefit is proper interoperability with classes written in other languages (for
example, a managed C++ class can inherit from a Visual Basic.NET class). An example of a restriction is that a managed class can only inherit from one base class. Any
restrictions, such as this one, are designed to prevent common programming errors.

105 What is strong name?
A name that consists of an assembly's identity—its simple text name, version number, and culture information (if provided)—strengthened by a public key and a digital
signature generated over the assembly.

106 What is portable executable (PE)?
The file format defining the structure that all executable files (EXE) and Dynamic Link Libraries (DLL) must use to allow them to be loaded and executed by Windows. PE
is derived from the Microsoft Common Object File Format (COFF). The EXE and DLL files created using the .NET Framework obey the PE/COFF formats and also add
additional header and data sections to the files that are only used by the CLR. The specification for the PE/COFF file formats is available at
http://www.microsoft.com/whdc/hwdev/hardware/pecoffdown.mspx

107 What is Code Access Security (CAS)?
CAS is the part of the .NET security model that determines whether or not a piece of code is allowed to run, and what resources it can use when it is running. For
example, it is CAS that will prevent a .NET web applet from formatting your hard disk.

108 Which namespace is the base class for .net Class library?
system.object

109 What is serialization in .NET?
Serialization is the process of converting an object into a stream of bytes.

110 What is Deserialization in .NET?
Deserialization is the opposite process of serialization, creating an object from a stream of bytes.

111 What is exception handling?
When an exception occurs, the system searches for the nearest catch clause that can handle the exception, as determined by the run­time type of the exception. First,
the current method is searched for a lexically enclosing try statement, and the associated catch clauses of the try statement are considered in order. If that fails, the
method that called the current method is searched for a lexically enclosing try statement that encloses the point of the call to the current method. This search continues
until a catch clause is found that can handle the current exception, by naming an exception class that is of the same class, or a base class, of the run­time type of the
exception being thrown. A catch clause that doesn't name an exception class can handle any exception.
Once a matching catch clause is found, the system prepares to transfer control to the first statement of the catch clause. Before execution of the catch clause begins, the
system first executes, in order, any finally clauses that were associated with try statements more nested that than the one that caught the exception.
Exceptions that occur during destructor execution are worth special mention. If an exception occurs during destructor execution, and that exception is not caught, then
the execution of that destructor is terminated and the destructor of the base class (if any) is called. If there is no base class (as in the case of the object type) or if there is
no base class destructor, then the exception is discarded.

112 What are the contents of assembly?
In general, a static assembly can consist of four elements:
• The assembly manifest, which contains assembly metadata.
• Type metadata.
• Microsoft intermediate language (MSIL) code that implements the types.
• A set of resources.

113 What are the different types of assemblies?
Private, Public/Shared, Satellite

114 What is the difference between a private assembly and a shared assembly?
1. Location and visibility: A private assembly is normally used by a single application, and is stored in the application's directory, or a sub­directory beneath. A shared
assembly is normally stored in the global assembly cache, which is a repository of assemblies maintained by the .NET runtime. Shared assemblies are usually libraries of
code which many applications will find useful, e.g. the .NET framework classes.
2. Versioning: The runtime enforces versioning constraints only on shared assemblies, not on private assemblies

115 How to find methods of a assembly file, without using ILDASM?
Reflection

116 What is the difference between ref & out parameters?
An argument passed to a ref parameter must first be initialized. Compare this to an out parameter, whose argument does not have to be explicitly initialized before
being passed to an out parameter.

117 What is the difference between Array and Arraylist?
As elements are added to an ArrayList, the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling TrimToSize or
by setting the Capacity property explicitly.

118 What is Jagged Arrays?
A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an
"array­of­arrays."

119 What are indexers?
Indexers are similar to properties, except that the get and set accessors of indexers take parameters, while property accessors do not.

120 What is Interop Services?
The common language runtime(CLR) provides two mechanisms for interoperating with unmanaged code:
• Platform invoke, which enables managed code to call functions exported from an unmanaged library.
• COM interop, which enables managed code to interact with COM objects through interfaces.
Both platform invoke and COM interop use interop marshaling to accurately move method arguments between caller and callee and back, if required.

121 What is RCW?
RCW Means Runtime Callable Wrappers, The common language runtime(CLR) exposes COM objects through a proxy called the runtime callable wrapper (RCW).
Although the RCW appears to be an ordinary object to .NET clients, its primary function is to marshal calls between a .NET client and a COM object.

122 What is CCW?
CCW Means COM Callable Wrapper, A proxy object generated by the common language runtime (CLR). so that existing COM applications can use managed classes,
including .NET Framework classes, transparently.

123 What is Pinvoke?
Platform invoke is a service that enables managed code to call unmanaged functions implemented in dynamic­link libraries (DLLs), such as those in the Win32 API. It
locates and invokes an exported function and marshals its arguments (integers, strings, arrays, structures, and so on) across the interoperation boundary as needed.

124 What is side­by­side Execution?




                                                                                                                                                                  Page 9 of 49
Side­by­side execution is the ability to run multiple versions of an application or component on the same computer. You can have multiple versions of the common
language runtime, and multiple versions of applications and components that use a version of the runtime, on the same computer at the same time.

125 How you will Hide Column(s) in the Windows Forms DataGridView Control?
Set the DataGridViewColumn.Visible property to false.
vb.net:
­­­­­­­
dataGridView1.Columns("CustomerID").Visible = False
c#.net:
­­­­­­
dataGridView1.Columns["CustomerID"].Visible = False;

126 What is the CAS ? .How to implement CAS ?
Code Access Security: It is .net security model that determines whether or not code is allowed to run .

127 What is an application domain?
Application domain is the boundary within which an application runs. A process can contain multiple application domains.
Application domains provide an isolated environment to applications that is similar to the isolation provided by processes.
An application running inside one application domain cannot directly access the code running inside another application domain.
To access the code running in another application domain, an application needs to use a proxy.
An application domain is a virtual process that serves to isolate an application. All objects created within the same application scope are created within the same
application domain. Multiple application domains can exist in a single operating system process, making them a lightweight means of application isolation.

128 In which Event all the Controls will be loaded(in asp.net)?
   1.   Init
   2.   Before Init
   3.   PageLoad
   4.   Arter Init and before PageLoad

Correct Ans : 3

129 Machine.config will be created automatically when you
   1.   Install Visual Studio
   2.   create an application
   3.   crate an console application
   4.   creating a class

Correct Ans : 1

130 In a connection­oriented socket, Which Protocal is used to establish a session (connection) between two IP address endpoints.
   1.   TCP protocol
   2.   UDP protocol
   3.   FTP
   4.   1) and 2)

Correct Ans : 1

131 Which Account type choose to minimize security risks?
   1.   NetworkService
   2.   LocalService
   3.   LocalSystem
   4.   User

Correct Ans : 3

132 In Which method to stops running thread ?
   1.   Thread.Suspend
   2.   Thread.Resume
   3.   Thread.Abort
   4.   Thread.Join

Correct Ans : 3

133 which of the following encoding type the largest file size?
   1.   UTF­8
   2.   UTF­16
   3.   UTF­32
   4.   ASCII

Correct Ans : 3

134 Where does global.asax Live?
   1.   in client mechine
   2.   in WebServices
   3.   in IIS
   4.   all the above

Correct Ans : 3

135 Which property of textbox cannot be change at run time?
   1. text & visible
   2. name & tab
   3. Both of above

Correct Ans : 2

136 ________ is new type introduced in C#4.0?
   1. Dynamic
   2. Common
   3. varDecimal




                                                                                                                                                        Page 10 of 49
   4. None of above

Correct Ans : 1

137 How can we access COM object in C#4.0?
   1. using IDispatch interface
   2. Using ICallable interface
   3. None of above

Correct Ans : 1

138 ________is one of the new feature added in C# 4.0 ?
   1. optional parameter
   2. introduced new language
   3. none of above

Correct Ans : 1

139 How many classes can a single .NET DLL contain?
Unlimited.

140 How many .NET languages can a single .NET DLL contain?
One.

141 Webservices support data reader.
   1. Treu
   2. False
   3. Maybe

Correct Ans : 2

142 Can we have two files with the same file name in GAC?
Yes, we can add two files with same name in GAC using versioning.

143 Difference between String and StringBuilder class?
the string class is immutable and therefore very inefficient if you need
to change it once it is constructed. For those cases, StringBuilder is
almost always a better choice. in case of string new object is create every time when we concate string.

144 Does ADO.NET supports automatic connection pooling?
Yes.
There is a pooling property with connection string. By default it is set to true.
Use this property to specify that a particular connection should not participate in the pool, but instead should be destroyed when it is closed.

145 Does CLR impose a strict versioning policy for the private assembly?
Answer is No. Private assembly are used by the application in which they are deployed. To use private assembly in any application, one needs to deploy them in the
application's directory. Versioning needs to done for shared assembly which are stored in GAC and used by multiple applications.

146 How .NET Framework 2.0 tackles the unhandled exceptions?
For .NET Framework 2.0,There is a change in the behavior in which on any unhandled exception, .NET Framework 2.0 just ends the worker process. This exception
cannot be caught as it is in the .Net framework 2.0, and when the .Net Framework "goes down", it also crashes the application. In .NET Framework 1.0 or 1.1, unhandled
exceptions were ignored.
Workaround for this is :
Add this section in your app.config file.


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
        <runtime>
            <legacyUnhandledExceptionPolicy enabled="true" />
        </runtime>
</configuration>



Thanks,
Virendra Dugar

147 What are the differences between .NET Framework 3.0 and 3.5?
­ .NET 3.0 is the combination of .NET Framework 2.0 with WCF, WPF, WF and cardspace.
­ .NET 3.5 is the combination of .NET Framework 3.0 with New AJAX controls, LINQ, Richer WCF support, Silverlight Support...

148 What is Runtime Host ?
Ranging from Windows applications, Web applications to Mobile applications, CLR is designed to support various types of applications. .NET Framework provides
different types of runtime hosts to manage the execution of application code(to load runtime in to process, create application domain within process, load user code in
to application domain) and provides various services to the application.
Runtime hosts included in .Net framework are : ASP.NET, Microsoft Internet Explorer and windows shell.

149 In how many ways you can deploy an Asp.Net Application?
   1.   XCopy deployment
   2.   PreCompiled deployment
   3.   SetUp Program deployment
   4.   all the above

Correct Ans : 4

150 This serves as a wrapper for a globally unique identifier (GUID) for a COM class…
   1.   CSLID Structure
   2.   CLSDI Structure
   3.   CLSID Structure
   4.   None



                                                                                                                                                      Page 11 of 49
Correct Ans : 3

151 This is generalized Clipboard format containing view of the data, and a storage medium indicator…
   1.   TCFORMATE Structure
   2.   FORMATETC Structure
   3.   Both
   4.   None

Correct Ans : 2

152 This Contains values that are used to create buttons on a toolbar…
   1.   CMMBUTTON Structure
   2.   MMCBUTTON Structure
   3.   BUTTON Structure
   4.   None

Correct Ans : 2

153 This Enum is used with TextFieldParser Object to determine either fields are delimited or fixed width…
   1.   FieldType Enumeration
   2.   TypeOfField Enumeration
   3.   Both
   4.   None

Correct Ans : 1

154 This namespace provides classes to run the Assembly Registration tool from managed code…
   1. MSRegCode Namespace
   2. CodeReg Namespace
   3. RegCode Namespace

Correct Ans : 3

155 This namespace is used for constructing the communication pipeline between a host application and an add­in…
   1.   System.Pipeline
   2.   System.AddIn
   3.   System.Pipeline.AddIn
   4.   System.AddIn.Pipeline

Correct Ans : 4

156 To manage installer of custom componenet the namespace used is,…
   1.   System.Install
   2.   System.CustomConfigurationInstall
   3.   System.CustomConfiguration
   4.   System.Configuration.Install

Correct Ans : 4

157 Which one is faster ?
   1.   BitVector32
   2.   BitArray
   3.   Both are same
   4.   Can’t say

Correct Ans : 1

158 System.Collections.Specialized Namespace contains…
   1.   linked list dictionary
   2.   bit vector
   3.   Collections that contain only strings
   4.   All of above

Correct Ans : 4

159 HybridDictionary Class implements…
   1.   Hashtable while the collection is small, and then switching to a ListDictionary when the collection gets large
   2.   ListDictionary while the collection is small, and then switching to a when the collection gets large
   3.   Hashtable throughout the scope
   4.   ListDictionary throughout the scope

Correct Ans : 2

160 IOrderedDictionary elements can be accessed with,…
   1.   Key
   2.   Index
   3.   Both
   4.   None

Correct Ans : 3

161 Hashtable with the key and the value strongly typed to be strings rather than objects is with class,
   1.   DictionaryString Class
   2.   StringDictionary Class
   3.   DictionaryStronglyTyped Class
   4.   None




                                                                                                                         Page 12 of 49
Correct Ans : 2

162 ColorPalette Class provided colors are…
   1.   32­bit ARGB colors. inheritable
   2.   32­bit ARGB colors. Not inheritable
   3.   64­bit ARGB colors. inheritable
   4.   64­bit ARGB colors. Not inheritable

Correct Ans : 2

163 ColorMatrix Class is…
   1.   A 3 x 3 matrix the RGBA space
   2.   A 5 x 5 matrix the RGBA space
   3.   A 7 x 7 matrix the RGBA space
   4.   None

Correct Ans : 2

164 ColorMode specifies…
   1.   two modes for bitmap images
   2.   two modes for colormap
   3.   two modes for ColorMatrix
   4.   two modes for color component values

Correct Ans : 4

165 Scan0 is used to…
   1.   Pass Scan command
   2.   Get/set the address of the first pixel data in the bitmap
   3.   Both
   4.   None

Correct Ans : 2

166 ColorChannelFlag Enumeration is in…
   1.   ARGB color space
   2.   CMYK color space
   3.   RGBA color space
   4.   All

Correct Ans : 2

167 With which class you can compare types of images ? With which property ?
   1.   ImageFormat Class , Compare method
   2.   BitMapDataClass , Compare method
   3.   ImageFormat Class , Equals method
   4.   BitMapDataClass , Equals method

Correct Ans : 3

168 Base interface to know all contracts used for communication between auto updated components is…
   1.   IEnumeratorContract
   2.   Contract
   3.   IContract
   4.   None

Correct Ans : 3

169 This represents a symbol binder for managed code…
   1.   ISymbolBinder
   2.   ISymbolBinder1
   3.   Both
   4.   None

Correct Ans : 3

170 With which enum you can know whether a calendar is solar­based, lunar­based, or lunisolar­based…
   1.   CalendarType
   2.   CalendarBaseType
   3.   CalendarAlgorithmType
   4.   CalendarTypeBase

Correct Ans : 3

171 This class defines the period of daylight saving time…
   1.   DaylightStyle
   2.   DaylightTime
   3.   Daylight
   4.   All

Correct Ans : 2

172 Web.config info get stored in...
   1.   Application root file
   2.   registery
   3.   Both
   4.   As specified by user




                                                                                                       Page 13 of 49
Correct Ans : 1

173 Culture­specific display of digit(number)s can be achieved with...
   1.   NumberShapes Enum
   2.   DigitShapes Enum
   3.   ShapesDigits Enum
   4.   None

Correct Ans : 2

174 Which method is used to serialize an object into an XML document from Xmlserializer class?
The "Serialize" method is the first step of serialize process and used to create an XML document

175 can we assign Null value to Struct variable.
No , We cannot assign null to a struct variable, since structs are value type.

176 What is the difference between a Struct and a Class?
Structs are Value type variables and are stored on the stack, while Class are Reference type variables and are stored on the heap.
Struct do not support inheritance, while class supports inheritance. However struct can implements interface.
Struct should be used when you want to use a small data structure, while Class is better choice for complex data structure.

177 What is the .NET collection class that allows an element to be accessed using a unique key?
HashTable

178 What does the term immutable mean?
In object­oriented and functional programming, an immutable object is an object whose state cannot be modified after it is created.
The variable value may be changed, but the original immutable data value was discarded and a new data value was created in memory. Ex: String.
Making an object immutable is usually inappropriate if the object contains a large amount of changeable data.
So, For this reason .NET has the System.Text.StringBuilder class which is Mutable and appropriate for large amount of changeable data.

179 Can you store multiple data types in System.Array?
No, If the System.Array is of Some Particular Data Type.(Primitive Data Type)
yes, If the System.Array is of Object Type.
Ex :
create an array of objects.
int in = 50;
string st = "Fifty";
object [] obj = new object[2];
obj[0] = in;
obj[1] = st;

180 What exactly a Constructor is doing ?
Constructor Creates as well as Initialized the objects.

181 If a method is marked as protected internal who can access it?
Access is limited to the current assembly or types derived from the containing class

182 Why is Global.asax is used for ?
Global.asax is used To implement application & Session level events

183 What are Jagged Arrarys ?
A jagged array is really an array of arrays.
To create a jagged array, you declare the array of arrays with multiple sets of parentheses or brackets and indicate the size of the jagged array in the first set of brackets
(parentheses).

184 WHat is HttpModule
It's just like a filter. The Modules are called before and after the handler executes.
For example: BeginRequest, AuthenticationRequest event, EndRequest event etc. You may intercept , participate and modify each request.
Modules implement the IHttpMudule interface
Request generelly goes as IIS > Modules > Handlers

185 What are the major processes that handle a request in Dot Net ?
aspnet_inetinfo.exe is the process that takes care of IIS running.
aspnet_ISAPI.exe is the process that decides which extenstion has to handle the request for requested document.
aspnet_wp.exe is the Process that processes the actual CLR task for Managed Code.

186 What is the use of System.Web namespace?
System.Web namespace defines a number of namespaces used in the development of .NET web applications, including ASP.NET applications XML web services.

187 Which casing should be used to declare name of class, as per the Microsoft coding standard?
Pascal Casing. Class name should be declared with using Pascal Casing.
Example: Capitalize the first letter of every word, e.g. MyClassName.

188 Which casing should be used to declare name of interface, method and Namespace, as per the Microsoft coding standard?
Pascal Casing. Interface name should be declared with using Pascal Casing.
Example: Capitalize the first letter of every word, e.g. MyClassName.

189 Which casing should be used to declare name of Parameter, as per the Microsoft coding standard?
Camel Casing: Parameter name should be declared using Camel Casing.
Example: Capitalize the first letter of every word except the first word. e.g.myClassName.

190 How do we store the same named assemblies in GAC? Whether its possible?
Yes it is possible. By different versions of assembly we can store.

191 Can you please tell me about the typed dataset?
A typed dataset will be having the sehema with them as in an xml format.
It raises the compile time exceptions. Arranging data and giving relationship is possible through this.

192 What is the class to access FTP?
FtpWebRequest

193 Tell me a method to access a COM dll in .NET?
We can create a interop dll of COM to access in .NET

194 What is side­by­side execution? Can two application one using private assembly and other using Shared assembly be stated as a side­by­side executables?



                                                                                                                                                           Page 14 of 49
Side­by­side execution is the ability to run multiple versions of an application or component on the same computer. You can have multiple versions of the common
language runtime, and multiple versions of applications and components that use a version of the runtime, on the same computer at the same time. Since versioning is
only applied to shared assemblies, and not to private assemblies, two application one using private assembly and one using shared assembly cannot be stated as side­by­
side executables

195 Why string is called Immutable data Type?
The memory representation of string is an Array of Characters, So on re­assigning the new array of Char is formed & the start address is changed. Thus keeping the Old
string in Memory for Garbage Collector to be disposed.

196 How does assembly versioning work?
Each assembly has a version number called the compatibility version. Also each reference to an assembly (from another assembly) includes both the name and version of
the referenced assembly.The version number has four numeric parts (e.g. 5.5.2.33). Assemblies with either of the first two parts different are normally viewed as
incompatible. If the first two parts are the same, but the third is different, the assemblies are deemed as 'maybe compatible'. If only the fourth part is different, the
assemblies are deemed compatible. However, this is just the default guideline ­ it is the version policy that decides to what extent these rules are enforced. The version
policy can be specified via the application configuration file.

197 How does CAS work?
The CAS security policy revolves around two key concepts ­ code groups and permissions. Each .NET assembly is a member of a particular code group, and each code
group is granted the permissions specified in a named permission set.
For example, using the default security policy, a control downloaded from a web site belongs to the 'Zone ­ Internet' code group, which adheres to the permissions
defined by the 'Internet' named permission set. (Naturally the 'Internet' named permission set represents a very restrictive range of permissions.)

198 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

199 What is the difference between the value­type variables and reference­type variables in terms of garbage collection?
The value­type variables are not garbage­collected, they just fall off the stack when they fall out of scope, the reference­type objects are picked up by GC when their
references go null.

200 What's the advantage of using System.Text.StringBuilder over System.String?
StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it's being operated on, a new instance is
created.

201 What's a satellite assembly?
When you write a multilingual or multi­cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized
assemblies that modify the core application are called satellite assemblies.

202 Describe the difference between a Thread and a Process?
A Process is an instance of an running application. And a thread is the Execution stream of the Process. A process can have multiple Thread.
When a process starts a specific memory area is allocated to it. When there is multiple thread in a process, each thread gets a memory for storing the variables in it and
plus they can access to the global variables which is common for all the thread.

203 What is the difference between an EXE and a DLL?
You can create an object of Dll but not of the EXE.
Dll is an In­Process Component whereas EXE is an OUt­Process Component.
Exe is for single use whereas you can use Dll for multiple use.
Exe can be started as standalone where dll cannot be.

204 What is strong­typing versus weak­typing?
Strong typing implies that the types of variables involved in operations are associated to the variable, checked at compile­time, and require explicit conversion; weak
typing implies that they are associated to the value, checked at run­time, and are implicitly converted as required.

205 How do you generate a strong name?
.NET provides an utility called strong name tool. You can run this toolfrom the VS.NET command prompt to generate a strong name with an option "­k" and providing the
strong key file name. i.e. sn­ ­k < file­name >

206 What is the difference between a Debug and Release build?
The Debug build is the program compiled with full symbolic debug information and no optimization. The Release build is the program compiled employing optimization
and contains no symbolic debug information. These settings can be changed as per need from Project Configuration properties. The release runs faster since it does not
have any debug symbols and is optimized.

207 Explain the importance and use of each, Version, Culture and PublicKeyToken for an assembly.
This three alongwith name of the assembly provide a strong name or fully qualified name to the assembly. When a assebly is referenced with all three.
PublicKeyToken: Each assembly can have a public key embedded in its manifest that identifies the developer. This ensures that once the assembly ships, no one can
modify the code or other resources contained in the assembly.
Culture: Specifies which culture the assembly supports
Version: The version number of the assembly.It is of the following form major.minor.build.revision.

208 How to install a strong named assembly to GAC at command prompt?
We can use a developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by the .NET Framework SDK or Use Windows Explorer to drag assemblies into
the cache.
To install a strong­named assembly into the global assembly cache at the command prompt, type the following command:
gacutil I Asembly_name
In this command, assembly_name is the name of the assembly to be installed in the GAC.

209 What is GAC?
The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer. You should share assemblies by installing
them into the global assembly cache only when you need to.
Just copy and paste your assembly to the GAC. But assemblies deployed in the global assembly cache must have a strong name. When an assembly is added to the global
assembly cache, integrity checks are performed on all files that make up the assembly.

210 How to create Key Pair?
You can create a key pair using the Strong Name tool (Sn.exe). Key pair files usually have an .snk extension. To create a key pair at the command prompt, type the
following command:
sn k
In this command, file name is the name of the output file containing the key pair. The following example creates a key pair called myKey.snk.
sn ­k myKey.snk

211 What do you mean by ActiveX components?
ActiveX control is a special type of COM component that supports a User Interface. Using ActiveX Control in your .Net Project is even easier than using COM component.
They are bundled usually in .ocx files.

212 Which namespace in .NET is used in networking programming?
System.Net

213 What is the name of C# command line compiler?
csc.exe

214 What is an Assembly in .NET?
When you compile an application, the MSIL code created is stored in an assembly.Assemblies include both executable application files(.exe files)& libraries(.dll
extension)for use by other application.




                                                                                                                                                          Page 15 of 49
In addition to containing MSIL,assemblies also include met information(i.e. information about the information contained in assembly,also called as meta­data)and
optional resources(sound and picture file, etc).The meta information enables assemblies to be fully self­descriptive.You need no other information to use an
assembly,meaning you avoid situations such as failing to odd required data to the system registry and so on,which was often a problem when developing with other
platforms.

215 What is the base class for all .NET classes?
System.Object

216 Why HashTable is used?
It is a .NET class that allows an element to be accessed using a unique key. It is mainly used in database programming.

217 Which namespace is used to create a multi­threaded application?
System.Threading

218 What is the role of compiler?
Compiler translates a high level language into machine language.

219 What is the namespace to use LINQ to XML?
System.Xml.XLinq

220 What are the elements inside an assembly?
A .NET assembly consists of the following elements,
A Win32 File Header
A CLR file header
CIL code
Type Metadata
An assembly manifest
Optional embedded resources

221 what is Reflection?
Reflection is the feature in .Net, which enables us to get some information about object in runtime. That information contains data of the class. Also it can get the names
of the methods that are inside the class and constructors of that object.
program should use the reflection derived from namespace System.Reflection .
using reflection can dynamically load assembly.

222 what namespace is used for the controls in a mobile web application?
System.Web.UI.MobileControls

223 Which assembly is used for Mobile web application?
System.Web.Mobile

224 Which file sets the environment variables for Visual Studio?
The vsvars32.bat sets the environment variables for Visual Studio. You can find it from %Microsoft Visual Studio 2008\Common7\Tools\vsvars32.bat.
When you start the Visual Studio 2008 command prompt it automatically runs vsvars32.bat.

225 Which namespace provides classes for Regular Expression?
System.Text.RegularExpressions namespace provides classes for Regular Expression

226 What is the use of System.SystemException namespace?
System.SystemException provide different classes to handle fatal as well as non fatal errors.

227 Which class is the base class of all the exception classes?
System.Exception class is the base class of all the exception classes in .NET.

228 Which namespace is used to work with RSS feeds in .NET?
System.ServiceModel.Syndication namespace is used to work with RSS feeds in .NET.

229 Which namespace is used to create an Exception Tree?
System.Data.Common.CommandTree namespace provide classes to create an Exception Tree.

230 How can we open the disassembler from Dot Net Command prompt ?
ILDASM (Intermediate Language Disassembler) is installed along with Visual Studio. You can found it inside the Visual Studio SDK Folder.
Version folder name will be depends on your .NET Framework version.
As for Example,
C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\
Now With the help of command

ILDASM

we can open it from Visual Studio Command Prompt.
We can open the ibuilt disassembler provided with framework to check the assembly information.

Modified By :
Moderator 3

231 Sorting on a Datatable
By using a datatable we can sort the data with out going for a dataview.
DataTable dt = new DataTable();
dt.Select(" select criteria if any " , " sort string ")

232 What is a DependencyProperty and How to implement it?
DependencyProperty is set to enable declarative code to alter the properties of an object which reduces the data requirements by providing a more powerful notification
system regarding the change of data in a very specific way. In .NET, there are two types of properties. One is the normal property & another is the DependencyProperty
which has added functionality over the normal property.
Now, let us discuss on how to implement such DependencyProperty to give a powerful notification on data change:
First of all, implement the UserControl class from INotifyPropertyChanged interface:


public partial class MyUserControl : UserControl, INotifyPropertyChanged
{
       public event PropertyChangedEventHandler PropertyChanged;
       protected void OnPropertyChanged(string propertyName)
       {
              if (PropertyChanged != null)
              {
                     PropertyChanged(this, new PropertyChangedEventArgs(propertyName));



                                                                                                                                                        Page 16 of 49
               }
         }
}



Create your own normal Property, lets say the name of the property is “Caption”.


public string Caption
{
         get { return GetValue(CaptionProperty).ToString(); }
         set { SetValue(CaptionProperty, value); }
}



Now, register the DependencyProperty to the CLR by calling the Register method by passing the property field that you used to store the data in earlier step:


public static readonly DependencyProperty CaptionProperty = DependencyProperty.Register("Caption", typeof(string), typeof(My



The name of the identifier field of the DependencyProperty will be same as you used in the property after appending “Property” at the end. In this example, our Property
name is “Caption”, hence our identifier field name is “CaptionProperty”. Add the PropertyMetaData with default value & callback event handler within the Register
method as mentioned in the above code. Mark the identifier as static & readonly so that this will be unique to the CLR.
Now, implement the OnCaptionPropertyChanged event handler:


private static void OnCaptionPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
{
         MyUserControl myUserControl = dependencyObject as MyUserControl;
         myUserControl.OnPropertyChanged("Caption");
         myUserControl.OnCaptionPropertyChanged(e);
}


private void OnCaptionPropertyChanged(DependencyPropertyChangedEventArgs e)
{
         txbCaption.Text = Caption;
}



The implementation of the DependencyProperty is complete. You can either call it from XAML:


<local:MyUserControl Caption="My First Dependency Property Example" />



or from Code behind:


MyUserControl myUserControl = new MyUserControl();
myUserControl.SetValue(MyUserControl.CaptionProperty, "My First Dependency Property Example");



233 What is Covariance and Contravariance ?
Assigning a string to an object from specific type to a more general type is called covariance.
In contrast, assigning an array of objects to an array of strings, from general type to a more specific type, is referred to as contravariance.

234 What is equivalent for regsvr32.exe in .NET?
In .NET we have regasm to register and unregister assemblies through .NET.

235 Which design pattern is implemented in the below code snippet? using System; public class MyClass { private static MyClass instance; private MyClass() {} public
static MyClass Instance { get { if (instance == null) { instance = new MyClass(); } return instance; } } }
    1.   Abstract Factory
    2.   Builder
    3.   Singleton
    4.   Factory Method

Correct Ans : 3 In the question snippet, only one instance will be created and served every time, so its Singleton Design Patter.

236 Which NameSpace is used to get the information of events about the system, devices like Hard disk serial No, Operating System and Processor?
    1.   System.Diagnostics
    2.   System.DirectoryServices
    3.   System.Media
    4.   System.Management

Correct Ans : 4 System.Management consists of ManagementObjects class which will have the information about devices and OS.

237 What are the Expansions of MSIL, JIT, CLR, CTS, CLS, RCW?




                                                                                                                                                      Page 17 of 49
1. MSIL ­ Microsoft Intermediate Language.
2. JIT ­ Just­In­Time compiler .
3. CLR ­ Common Language Runtime.
4. CTS ­ Common Type System.
5. CLS ­ Common Language Specification.
6. RCW ­ Runtime Callable Wrapper.

238 Which namespace contains the classes that required to serialize an object? Explain Object Serialization?
System.Runtime.Serialization
Object serialization is the process of reducing an object instance into a format that can be either stored to disk or transported over a network.

239 Explain how to retrieve resources using ResourceManager class?
ResourceManager class is used to retrieve resources at run time.
• Create a ResourceManager with resource file name and the resource assembly as parameters.
• After having created, you can use ResourceManager.GetString method to retrieve a string.
• Use the ResourceManager.GetObject method to retrieve images and objects from a resource file.

240 What is code security? What are the types?
.NET framework provides the security features to secure code from unauthorized users.
There are two types of code security:
Role based security: This authorizes user.
Code access security: This protects system resources from unauthorized calls.

241 Define Principal object?
The Principal object represents authenticated users. It contains information about user’s identity and role. You have Principal Permission object in .NET Framework that
specifies user and its role. It has Demand method that checks the current user or Principal against the name and role specified in the Principal Permission.

242 Explain declarative and imperative security?
Security checks can be applied in two ways that is imperatively or declaratively.
Declarative security is applied by associating attribute declarations that specify a security action with classes or methods.
Imperative security is applied by calling the appropriate methods of a Permission object that represents the Principal (for role based security) or system resource (for
code access security).

243 Define context menu?
The menu that you get when you right­click is called the context menu. It is a modular piece of markup code that can move around the page. It consists of two distinct
blocks, one is the user interface and another is the script code to connect the UI to it.

244 Explain the similarities and differences between arrays and collections?
• The Array class is not part of the System.Collections namespace. But an array is a collection, as it is based on the list interface.
• Array has a fixed capacity but the classes in the System.Collections namespace don’t have fixed capacity. That’s why array is a static container, but collection is dynamic
container.
• Collections objects have a key associated with them. You can directly access an item in the collection by the key. But to find a specific item in an array, unless you don’t
know the index number you need to traverse the array to find the value.

245 What is break mode? What are the options to step through code?
Break mode lets you to observe code line to line in order to locate error.
The VS.NET provides following options to step through code.
• Step Into
• Step Over
• Step Out
• Run To Cursor
• Set Next Statement

246 How do we step through code?
Stepping through the code is a way of debugging the code in which one line is executed at a time.
There are three commands for stepping through code:
Step Into: This debugging mode is usually time­consuming. However, if one wants to go through the entire code then this can be used. When you step into at a point and
a function call is made somewhere in the code, then step into mode would transfer the control to the first line of the code of the called function.
Step Over: The time consumed by the Step into mode can be avoided in the step over mode. In this, while you are debugging some function and you come across
another function call inside it, then that particular function is executed and the control is returned to the calling function.
Step Out: You can Use Step Out when you are inside a function call and want to return to the calling function. Step Out resumes execution of your code until the
function returns, and then breaks at the return point in the calling function.

247 What are the debugging windows available?
The windows which are available while debugging are known as debugging windows.
These are: Breakpoints, Output, Watch, Autos, Local, Immediate, Call Stacks, Threads, Modules, Processes, Memory, Disassembly and Registers.

248 In .NET, which namespace contains classes used to a)Create a localized application? b)Develop Web Forms? c)Create Web server controls? d)Access Sql Server? e)
Read a File?
a)System.Globalization, System.Resources
b)System.Web
c)System.Web.UI.WebControls
d)System.Data.SqlClient
e)System.IO

249 What is the concept of Automatic Memory Management in ASP.NET?
The .NET framework has introduced a concept called Garbage collector. This mechanism keeps track of the allocated memory references and releases the memory when
it is not in reference. Since it is automatic, it relieves the programmers to manage unused allocated memory. This concept of managing memory is known as Automatic
Memory Management.

250 What are the ways to retain variables between requests?
Below there are different ways to retain variables between requests. That is:
Context.Handler: This object can be used to retrieve public members of the webform from a subsequent web page.
Querystring: Querystring is used to pass information between requests as part of the web address. Since it is visible to use, we can't use it to send any secured data.
Cookies: Cookies stores small amount of information on client side. But we can't reply on cookies since many clients can refuse cookies.
View state: View state stores items added to the pages. These properties are as hidden fields on the page.
Session state: Session state stores items that are local to the current session.
Application state: Application state stores items that are available to all users of the application.

251 Explain how to dynamically clone a menu in .NET?
Below are the steps to dynamically clone a menu in .NET:




                                                                                                                                                           Page 18 of 49
• Create an alternate MainMenu object.
• Clone the first menu with the CloneMenu method.
• Create additional menu items related to the application state.
• Then add the new menu items to the MenuItems collection of the top­level menu item cloned. This can be done by using the Add method to specify their order within
the collection by their index.
• Then assign the newly created MainMenu object to the form.

252 What are Merge module projects?
Merge module projects are used for the packaging of files or components that are shared between multiple applications.
A merge module (.msm) file includes files, resources, registry entries, and setup logic. The .msm file is merged into the deployment projects for consistent installation of
a component across multiple applications.

253 Describe XCOPY deployment. Under what conditions is it useful? When can it not be used?
XCOPY deployment is a simple method of deployment where the DOS command XCOPY is used to copy the application directory and any sub directories to the target
machine. You can use XCOPY deployment if your application has no dependency on shared files and requires no special actions to be taken upon deployment. If suppose
one application requires more complex deployment or references shared assemblies, there you should not use XCOPY.

254 Define the list of properties, methods and events included in SmtpClient class in the Framework?
Here is some partial list of the members of the SmtpClient class...
1) Properties:
• Host­ The name or IP address of your email server.
• Port­ The number of the port to use when sending an email message.
2) Methods:
• Send­ It enables you to send an email message synchronously
• SendAsync­ It enables you to send an email message asynchronously.
3) Events:
• Send Completed­ It is raised when an asynchronous send operation completes.

255 What is Network Load Balancing?
Network Load Balancing is a clustering technology offered by Microsoft as part of all Windows Server 2000 and Windows Server 2003 family operating systems. Network
Load Balancing uses a distributed algorithm to load balance network traffic across the number of hosts, helping to enhance the scalability and availability of IP­based
services, such as Web, Virtual Private Networking, Streaming Media, Terminal Services, Proxy, etc. It also provides high availability by detecting host failures and
automatically redistributing traffic to operational hosts.

256 How can you change priority and what the levels of priority are provided by .NET?
Thread Priority can be changed by using Threadname.Priority = ThreadPriority.Highest .
Following are different levels of Priority provided by .NET:­
• ThreadPriority.Highest
• ThreadPriority.AboveNormal
• ThreadPriority.Normal
• ThreadPriority.BelowNormal
• ThreadPriority.Lowest

257 What is an application pool?
1. An application pool is a set of one or more websites in IIS served by the worker process.
2. Each application pool has its own worker process.
3. This process isolation prevents processing from interfacing with one another.

258 How can you bind the debug failed assembly?
You can bind the debug failed assembly by using Assembly Binding Log Viewer (fuslogvw.exe ) and also you can find out the searched paths.

259 What is the Difference between Compiler and Translator?
Compiler converts the program from one computer language to another computer language that is translating from a higher level language to a lower level language. A
compiler has to cope with any valid syntax in the source language, and generate semantically equivalent code in the target language.
Translator which translate one language to many other language or else we can say a translator is usually translating from a high level language to another high level
language, or from a low level language to a high level language. A translator usually has a fixed body of code that is required to translate the program.

260 In which way you can copy the COM component to the server and register?
These components provides setup program to install or remove them from the system. Suppose the component doesn’t provide a setup program, you can copy it to the
server and register it using the MFC RegSvr32.exe utility, as shown below:
RegSvr32 MyComname.dll

261 Can we create web application with out web.config file?
Yes we can create,
if there is a web.config file it will take settings from directory level web.config file. if there is no web.config file in application level then it will go for machin.config file for
setting.
So we can create web application without web.config file

262 Which is an example of Pascal Casing ?
   1. Forecolor
   2. ForeColor
   3. foreColor

Correct Ans : 2 Pascal casing is a namimg convention in which the first letter in the identifier and the first letter of every subsequent concatenated word are capitalized.

263 Which class defines the methods for implementing drawings, shapes, writing strings in a GUI based application?
Graphics class defined by the System.Drawing namespace contains methods
like DrawString, DrawArc, DrawImage, DrawEllipese which are used for implementing
Drawings, shapes, writing strings etc.

264 What will be the output of this program? using System; class Class2 { Class2() { static int i; i++; Console.WriteLine(i); } static void Main() { Class2 a = new Class2();
Class2 b = new Class2(); } }
Compiler error "Modifier static is not valid for this item"
static variables are declared at Class level.

265 Can classes be marked as protected or private ?
Yes, a class can be marked as protected but we have to use the concept of nested classes for that .
For a class can be marked as private we have to use the concept of nested classes for that or declare a class in a structure
example: These are valid examples:
class A
{
protected class B
{
}
}
class C
{



                                                                                                                                                                   Page 19 of 49
private class D
{
}
}
//Class can also be private inside a structure
struct empz
{
private class Class3
{
}
}
It is OK.
If a class is declared below a namespace it cannot be marked as protected or private.

266 Do events have a return type?
Yes, events return a delegate.
example: delegate void dd();
event dd myevent;
myevent is the event name and returns the delegate dd;

267 Which encoding does not allow Chinese or Arabic characters?
    1.   UTF­32
    2.   UTF­16
    3.   ASCII
    4.   none of these

Correct Ans : 3 ASCII encoding does not allow Chinese or Arabic characters. UTF encoding supports character sets of may languages. UTF­32 and UTF­16 are both OK.
ASCII is English based.

268 What are the differences between an interface and an abstract class.
Both interface and an abstract class cannot be instantiated and are implemented
by inheriting them in other classes.
The differences between them are:
1)Interfaces
a)All members are public by default.
b)They cannot contain fields.
c)No coding of the methods or the properties is allowed.
d)They do not provide implementation.
e)Interfaces support multiple inheritance
f)abstract keyword is not there before the interface or its members names.

Abstract classes
a)All members are private by default. We can put modifiers like
public, protected before the abstract class members.
b)They can contain fields.
c) coding of the methods or the properties is allowed.(nonabstract)
we can also declare abstract methods(methods with no coding) and only
the declaration
d)They can provide implementation. An abstract class can implement an
interface
e)Abstract classes support single inherritance
g)abstract keyword is required before their names and also before the
abstract methods or properties.

269 Which dll is known as the dll for microsoft .NET runtime ?
    1.   mscorlib.dll
    2.   mscoree.dll
    3.   System.dll
    4.   none

Correct Ans : 2 mscoree.dll is the dll.It is used in code execution

270 What is the difference between casting and boxing?
casting is the technique using which we convert data of one
type to data of another type.
It is like a main category of boxing.
boxing is a sub category of casting which deals with
converting a value type to a reference type.
example:
1) double d=245.66;
//casting: conversion between 2 value types
int a=(int)d;

2) int f=200;
object z=f; //casting as well as boxing: conversion of a value type to a reference type.

271 Which of these files are in the Config folder of the .net Framework?
    1.   Machine.Config
    2.   Web.Config
    3.   Web.Config.Comments
    4.   Machine.Config.Comments

Correct Ans : All of these files are there in the Config folder. The files with .Comments suffix in the end are used only for documentation.

272 Which class is used to represent the Exceptions thrown by the CLR?
    1. ApplicationException
    2. SystemException
    3. Both of these

Correct Ans : 2 SystemException is the class used to represent the CLR thrown Exceptions. ApplicationException is for the errors thrown by the user generated code.




                                                                                                                                                     Page 20 of 49
273 Which of these classes is not derived from MemberInfo class?
   1.   EventInfo
   2.   FieldInfo
   3.   PropertyInfo
   4.   None of these

Correct Ans : 4 All of these classes are derived from the MemberInfo class and used in Reflection.

274 How you load dynamic assembly? How will create assemblies at run time?
You can load the assembly dynamically by using classes from the System.Reflection namespace.

Assembly x = Assembly.LoadFrom( “Custom.dll” );



You can create assembly by using classes from System.CodeDom.Compiler

275 What is PInvoke?
Pinvoke (PlatForm Invoke) features of the .NET enables .NET Code to call functions from unmanaged libraries like user32.dll, kernel32.dll. Thse libraries contain Window
API functions like FlashWindow, GetComputerName respectively.
FlashWindow can be used to blink the form's caption bar.
GetComputerName can be used to retreive the computer's name.

276 What is XSL?
XSL stands for Extensible Style Language:
It is basically a formatting language using which we can convert an XML document
into an HTML document. XSL is similar to CSS but specific for XML documents.
XSL has its own set of namespaces and elements using which we can apply the formatting.

277 Differences between Window and Web Forms
Window Forms:
1)They do not need a web browser or web server to execute.
2)They execute through their respective exe files
3)They run on the same machine they are displayed on.
4)Their single instance exists until we close them or dispose them through coding
5)Used for developing games, inventory management, system utiltites etc.
6)They run under Code Access Security.

Web Forms:
1)They need a web browser as well as a web server(on the server machine only).
2)They execute through the dll of the web application which is then processed by IIS and the .net framework.
3)They run on a remote server and are displayed remotely on the clients.
4)Every time they are submitted, their new instance is created.
5)Used in web site development.
6)They use role based security

278 Which of these collections can be made as readonly?
   1.   ArrayList
   2.   Stack
   3.   Hashtable
   4.   SortedList

Correct Ans : 1 Only ArrayList can be made as Readonly. It has got a static function known as ReadOnly which can be used to initialize an ArrayList variable that will be
just a snapshot of some ArrayList object reference.

279 What is the difference between .NET 1.1,2.0,3.0,3.5 and 4.0 ?
The list of differences are huge. In interviews you normally need to short and sweet. So we will list down top 5 differences from each section.
So lets first start with the difference between 1.0 and 2.0.
Support for 64 bit application.
Generics
SQL cache dependency
Master pages
Membership and roles
Now the next difference .NET 2.0 and 3.0
=========================================
WCF
WPF
WWF
WCS ( card space)
3.0 and 3.5
==========================================
LINQ
Ajax inbuilt
ADO Entity framework
ADO data services
Multi targeting
Finally 3.5 and 4.0
===========================================
MEF
Parallel computing
DLR dynamic
Code contract
language runtime
Lazy initialization
20 top .NET interview questions
http://www.questpond.com




                                                                                                                                                         Page 21 of 49
280 Which of these collections uses keys to uniquely identify the data?
   1.   HashTable
   2.   SortedList
   3.   Both of these
   4.   None

Correct Ans : 3 Both HashTable and SortedList use keys to uniquely identify the data.

281 What is difference between out and ref in c#?
This is a great .NET Interview question and also very very confusing question. By default parameters are always passed by value to methods and functions.If you want to
pass data byref then you can use either out or ref keyword.
There are two big difference between these keywords one is the way data is passed between the caller code and method and second who is responsible for initialization.
Way the data is passed(directional or bi­directional)
==================================================
When you use OUT data is passed only one way i.e from the method to the caller code.
When you use REF , Data can be passed from the called to the method and also vice versa.
Who initializes data
==============================================
In OUT the variables value has to be intialized in the method. In REF the value is initialized outside the method by the caller.
The most important thing the interviewer will like to hear from you When to use when
======================================================
OUT will be used when you want data to be passed only from the method to the caller.
REF will be used when you want data to be passed from the called to the method and also vice versa.
My 100 .NET Interview questions http://www.questpond.com

282 What is .NET Framework?
.NET (.Network Enabled Technologies) is a collection of development tools
developed by the Microsoft Corporation that enables the developers to develop
and execute a large variety of applications
example: Console,Windows,Web,WPF,WCF, Web Services, Window Services,
Mobile Applications.
.NET Framework consists of:
1)CLR: (Common Language Runtime):
2)FCL: (Framework Class Llivraries)
3)Languages, Language Compilers
CLR is the set of components(also called as the execution engine) and provides
us with many runtime services.
example:
1)Managing code execution.
2)Menory management and Garbage Collection.
3)Exception handling management
4)Security and Code Verification
5)MultiThreading support
6)Cross Language interoperability using CTS and CLS.
FCL provides us with the predefined class libraries which have over thousands of
classes that can be used in development and execution.
example: System.Data.dl
System.Windows.Forms.dll
System.dll
mscorlib.dll
Languages :example: VB.NET, C#,VC++
Each language ahs its own set of compilers
ex: vbc for vb.net, csc for csharp.
Coompilers are used to compile the code and generate the executable files.(Assemblies)

283 What is CLS?
CLS:
Common Language Specification:
It is a set of the programming rules which every .NET language must follow.
CLS is used so that the code written in one language is interoperable with the code written in another language. The different .NET languages code is compiled into MSIL
Code. CLS defines the infrastructure for the MSIL Code. The CLR processes the MSIL code and help in its execution. This ensures the language interoperability.

EXAMPLES OF CLS:
1)Common set of data types for all the languages( CTS)
Int32 datatype is implemented as int in C# and as integer in VB.NET
2)Interfaces cannot have static methods.It applies to all the .NET languages.
The Types which follow the CLS rules are also called as CLS Compliant types.
CLS compliant languages:
VB.NET,C#, VC++
Use of CLS:
A class written in VB.NET can be used in C# and vice­versa.

For the complete list of CLS features, please visit this link.

http://msdn.microsoft.com/en­us/library/12a7a7h3(VS.71).aspx

284 Which of these is a valid path declaration?




                                                                                                                                                      Page 22 of 49
   1.   string s="c:\\demo.txt";
   2.   string s="c:/demo.txt";
   3.   string s=@"c:\demo.txt";
   4.   all of these

Correct Ans : 4 All of the above declarations are correct. For single slash, we can use forward slash. For back slash, either use \\ or @ followed by \.

285 Differences between method overloading and method overriding
Method Overloading and Method Overriding are both the techniques used to implement FUNCTIONAL POLYMORPHISM
They enhance the methods functionality using their respective features.
overloading:
1) It involves having another method with the same name in a class or its derived class.
2)can be implemented with or without inheritance.
3)It is implemented by:
a)changing the number of parameters in different methods with same name.
b)changing the parameter data types (if the number of parameters are same)
c)changing parameter order.
4)applicable to static as well as non static methods:
5)no keywords needed before the method names in C#.
6)also called as COMPILE TIME Polymorphism.
example: int add(int a, int b)
{
return a+b;
}
int add(int a)
{
return a*5;
}



Overriding:
1) It involves having another method with the same name in a base class and derived class.
2)always needs inheritance.
3)It is implemented by having two methods with same name, same signature, but different implementations (coding)in a base class and derived class
4)applicable to nonstatic, nonprivate methods only.access modifiers of the methods are not changed in the base and derived classes.
5)virtual and override keywords are needed before the method names in base and derived classes.
For overriding in firther classes, override keyword will be used,
6)RUN TIME Polymorphism
example:
class A
{
public virtual void demo()
{
}
}
class B:A
{
public override void demo()
{
}
static void Main()
{
B obj=new B();
obj.demo();
}
}

286 Which namespace defines the collection classes?
Collection classes are defined by 2 namespaces
1)System.Collections:
defines ArrayList, Stack, Queue
2)System.Collections.Generic
Defines the Generic Collections
example: List<>,Stack<>, Queue<>

287 Difference between an Assembly and DLL
An assembly is basically a file that contains the MSIL Code and Metadata.
It is the smallest unit of deployment of .NET applications.
An assembly in .NET has 2 extensions (.exe and .dll)
dll : dynamic link library.
So, we can say a dll is an assembly, but an assembly may not always be a dll
In other words, dll is one type of an assembly

288 OOP .NET Interview question :­ What is Polymorphism?
This is a nice and simple OOP interview question.
As the name says POLY (Many) MORPHISM (Change). Polymorphism is the ability of the object to behave differently under different conditions. For instance a simple
user object can behave as a admin user or as a simple user depending on conditions.
There are two ways of doing polymorphism dynamic and static. Static polymorphism is achieved by using method overloading and dynamic polymorphism is achieved by
using method overriding. Please note do confuse with overloading and overriding while answering this question. Many .NET developers make a nice versa statement
leading to lot of confusion.
.NET interview question and answer http://www.questpond.com




                                                                                                                                                           Page 23 of 49
289 What is MSIL?
MSIL : Microsoft Intermediate Language
Definition:
It is a set of CPU independent instructions that are generated by the language compiler when the project is compiled. MSIL code is not executable but further
processed by CLR/other runtime environments before it becomes executable.
MSIL is contained in the assembly of the .NET application.
Features:
MSIL instructions map to the code that is written in .NET Language and are used for loading, storing, initializing, and
calling methods on objects, as well as for
arithmetic and logical operations, control flow, direct
memory access, exception handling, and other operations.
CLS(Common language Specification) provides the infrastructure for MSIL.

Benefits:
1)MSIL provides language interoperability as the code in any .NET language is compiled into MSIL.
2)Same performance for all the .NET Languages:
3)Support for different runtime environments:
CLR can understand MSIL.
Non .NET environments also support MSIL.
­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
The JIT Compiler in CLR converts the MSIL code into native machine code which is then executed by the OS

290 Difference between Finalize and Dispose methods ?
Finalize and Dispose are both known as Finalizers.
They are the methods used to deallocate the memory of the objects
Differences:
FINALIZE
1)Finalize belongs to the Object class.
2)It is automatically called by the Garbage Collection mechanism when the object goes out of the scope(usually at the end of the program)
It is not called by the User Code.
In C#, suppose there is a class known as emp
class emp
{
//This is the destructor of emp class
~emp()
{
}
//This destructor is implicitly compiled to the Finalize method.
}
3)Not suitable for instant disposing of the objects.Sloer method.

DISPOSE
1)Dispose belongs to the IDisposable interface
2)we have to manually write the code to implement it(User Code)
ex: if we have emp class we have to inherit it from the IDisposable interface
and write code. We may have to suppress the Finalize method using GC.SuppressFinalize() method.
3)Faster method for instant disposal of the objects
Example: user interface Controls. Forms, SqlConnection class have built in implementaion of Dispose method.

291 How many classes a dll can contain?
There is no limit.
However, it depends upon the hardware space available and the performance
related parameters.

292 What is Serialization?
Serialization:
It is the process through which we can convert an object into a format that can be persisted or transported.
During this process, the public and private fields of the object and the name of the class,including the assembly containing the class, are converted to a stream of bytes,
which is then written to a data stream.
Serialization allows us to save the state of objects from memory to files.
It is most commonly used in Web Services/Remoting applications.

293 Can abstract class have constructors?
Yes, an abstract class does have a constructor.
It will be called when it subclass is instantiated.
example:

 abstract class bank
        {
                public bank()
                {
                        Console.WriteLine("bank");
                }


        }
        class icici : bank
        {
                icici()
                {




                                                                                                                                                         Page 24 of 49
                    Console.WriteLine("icici");
             }
             static void Main()
             {
                    bank b = new icici();


             }
       }



//Output:
when the object of icici class is created,
They will be displayed in the output.
bank
icici

294 Difference between String.Empty and ""
String.Empty is a readonly field, while "" is a constant
Consider this code snippet.


private void button1_Click(object sender, EventArgs e)
             {
                    string s = textBox1.Text;
                    switch (s)
                    {
                          case String.Empty:
                                 MessageBox.Show("blank");
                                 break;
                    }



             }



//Compiler will generate an error
//A constant value is expected
//So, if we use "" in place of String.Empty, no error will be generated.

295 Difference between Environment.MachineName, SystemInformation.ComputerName and Dns.GetHostName
Environment.MachineName :
Environment is a class defined by System Namespace.
MachineName is its property.
It reads the NetBIOS name of local computer..
SystemInformation.ComputerName :
SystemInformation is a class defined by System.Windows.Forms Namespace
ComputerName is its property,
output:
Same as Environment.MachineName

Dns.GetHostName :
Dns is a class defined by System.Net namespace:
GetHostName is its method.
It gets host name of computer which refers to a domain name that has one or more associated IP adresses.

296 What will be the output of this code? using System; class A { class B { public string str = "welcome"; } } class Demo { static void Main() { B Obj = new B();
Console.WriteLine(Obj.str); } }
Answer:
The compiler will generate an error
The Type or Namespace 'B' could not be found.
It is because since B is the inner class, it is now private.
Solution:
1)we have to change the access modifier of B to internal/public
2)we have to give the full path of class B when creating the object
i.e. A.B obj=new A.B();
Then we can see the value of the field str in the output.

297 How can you specify the framework version targetted by your application?
In ASP.NET 4.0, we can write in web.config file like this:
A new attribute targetFramework has been added.
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation targetFramework="4.0" />




                                                                                                                                                        Page 25 of 49
</system.web>
</configuration>

298 Which controls cannot be placed on an MDI Form?
These controls cannot be placed on the MDI Form
1)Components :
example: BackgroundWorker,
ImageList,
HelpProvider,
Timer
2)Printing:
example: PrintDocument, PrintDialog
3)Dialogs
example: ColorDialog,
SaveFileDialog
These controls are placed in the Component Tray window.
It is the window below the Form window anad can be viewed in Design mode
It contains all the controls which cannot be viewed even by default
when the application executes.

299 Difference between imperative and interrogative code.
Imperative code does not return a value. It just does performs an action.
example:
c#
void demo()
{
Console.WriteLine("welcme");
}
vb.net
sub procedures are imperative code.
sub dd()
end sub
Interrogative code does return a value.
c#
ex: int add(int a)
{
return a*5;
}
VB.NET FUNCTIONS
ex
function calc(byval a as integer) as integer
return a*5
end function

300 Difference between a Class and Component?
Class is a datatype that encloses data and function members.
It can be used for implementing the various OOPS features.
Component is a particular class that must implement the IComponent interface .It is the base class for all components in the common language runtime that marshal by
reference. Component is remotable and derives from the MarshalByRefObject class.
IComponent interface belongs to System.ComponentModel namespace.
So, we can say Component is subclassification of a class

301 Difference between event and delegate?
event:
1) It is a data member of a type(class/structure)
2)It is declared inside a type(class/structure)
3) It is used to generate notifications which are then passed to methods though
delegates.
delegate:
1)It is a datatype(reference type) that holds references of methods with
some signatures.also called as function pointer.
2)It may or may not be declared inside a class.
3)It is used as the return type of an event and used in passing messages from event to methods.

event­­>delegate­­>method
example:
namespace dd
{
//delegate declaration
delegate void first();
class cc
{
//event declaration
public first myevent;
}
}
example 2:
button1.Click+=new EventHandler(this.button1_Click);
(Windows Applications)
Click is the event that returns an instance of the EventHandler delegate.
EventHandler delegate has the reference of button1_Click event and that
helps in the communication betwen the Click event and button1_Click method

302 Is versioning applicable to private assemblies?
Yes, versioning is applicable to private assemblies too
There are 2 types of versions:
1)File version
2)Assembly version




                                                                                                                                                  Page 26 of 49
File version is the default version that is assigned to any .NET assembly
example: click a .exe and view its properties: File version would always be there
Assembly version is applicable when we create a shared assembly(assembly installed
in a GAC)
Private assemblies do not have Assembly version, but they do have File Version

303 What is Application Domain?
It is the execution boundary within which an application runs.
Application Domain is created inside a process.
One process can have multiple Application Domains.
Example:
Consider a Remoting scenario:
2 exe's of the client and the server are communicating with each other.
2 Application Domains will be created in the process of the server.
Process: In this case, it is the executable of the Operating System that will control the interaction of the client and server exe's.
the 2 exes's run in their Application Domains that will be created in the
execution area(in the RAM) of the OS exe.
Application Domains provide the isolation of the 2 exe's(i.e. the client and the
server).

304 What is Constructor Chaining?
We can chain the call of constructor from child class to base class depending on our requirement. This concept makes sure that the matching base class constructor must
be called based on the parameter passed to the child class constructor.
Example:


namespace ConsoleApplication1
{
       class A
       {
             public A(){
                   Console.WriteLine("Constructor A.");
             }
             public A(string s){
                   Console.WriteLine("Constructor A with parameter = {0}",s);
             }
             public A(string s,string t){
                   Console.WriteLine("Constructor A with parameter = {0} & {1}", s,t);
             }
       }


       class B:A
       {
             public B():base(){
                   Console.WriteLine("Constructor B.");
             }
             public B(string s):base(s){
                   Console.WriteLine("Constructor B with parameter = {0}", s);
             }
             public B(string s, string t):base(s,t){
                   Console.WriteLine("Constructor B with parameter = {0} & {1}", s, t);
             }
       }
       class Program
       {
             static void Main(string[] args)
             {
                   B b1 = new B();
                   B b2 = new B("First Parameter ", "Second Parameter");


                   Console.Read();
             }
       }
}



Output:
Constructor A.
Constructor B.
Constructor A with parameter = First Parameter & Second Parameter
Constructor B with parameter = First Parameter & Second Parameter

305 How many languages a .NET DLL can contain?




                                                                                                                                                    Page 27 of 49
    1.   one
    2.   two
    3.   none of these
    4.   any number

Correct Ans : 1 Only one language is there in a .NET DLL . It is the MSIL (Microsoft Intermediate Language) All the code is compiled into the MSIL. The MSIL provides
language inteoperability by using the CLS infrastructure.

306 Which of the following namespaces spans across multiple assemblies?
    1.   System.Data
    2.   System.Xml.linq
    3.   System
    4.   None

Correct Ans : 3 System namespace: It belongs to both System.dll and mscorlib.dll

307 What does a method's signature consist of?
    1.   name of the method and parameters
    2.   parameters only
    3.   name of the method ,parameters and return type
    4.   none of these

Correct Ans : 1 name of the method and parameters define the signatures of the method. return type of the method has nothing to do with a method's signatures.

308 What is an assembly manifest?
The assembly manifest is providing information to the .NET application at runtime. It provides the information like assembly's name, version, requested permissions, and
other assemblies that the .NET application references.
It describes the assembly to the managed hosting environment.
It acts as a directory to the modules, types, and resources in the assembly.

309 What is an application manifest?
The application manifest which gives information to the operating system, such as in which way the assembly should be deployed and will check whether administrative
elevation is required or not.
This is processed before the .NET­managed hosting environment loads to the assembly.

310 Which is true regarding the Delegates ?(select all that apply) a)They can be written in a class as well as in a structure. b)They can be static c)They are not
inherited
    1.   a
    2.   b
    3.   c
    4.   a,c

Correct Ans : 4 a and c are correct. delegates can be declared below namespaces as well as in a class or structure. Delegate classes are sealed. Delegates are not static
but they can refer to static methods.

311 You are creating emp class whose objects need to be sorted when in an ArrayList collection. How can you do that?
    1.   IEquatable interface
    2.   IFormattable interface
    3.   IComparable interface
    4.   none of these,

Correct Ans : 3 IComparable interface is correct. IEquatable allows two objects of a class to be compared for equality but sorting is not there. IFormattable is only for
formatting(Ex: Object­­­­>String)

312 Which of these gives us the method name that throws the current exception?
    1.   Source
    2.   InnerException
    3.   TargetSite
    4.   None of these

Correct Ans : 3 TargetSite is the property of Exception class gives us the method name Source: name of the application. InnerException: gives all exception details in case
of nested exceptions.

313 Which of these classes can be used to write string data?
    1.   File
    2.   StreamWriter
    3.   BinaryWriter
    4.   All of these

Correct Ans : 4 All of these can be used. File: File.CreateText() method StreamWriter: writes strings by default. BinaryWriter.Write(string s);

314 Which of these components can be used for printing?
    1.   PrintDocument
    2.   PrintPreviewDialog
    3.   PrintDialog
    4.   All

Correct Ans : 4 All of these can be used for printing. PrintDocument: In built method of Printing(Print) and event(PrintPage) PrintPreviewDialog: click the print icon in its
top PrintDialog:click the print button and write suitable code.

315 Difference between lock and Monitor.Enter()
lock keyword basically provides a shortcut to Enter method of Monitor class.
Monitor is used to provide thread synchronization.It means till the Thread in which the method is being used finishes its task, no other thread can access the object.
example:
lock (object)
{
}




                                                                                                                                                           Page 28 of 49
It is compiled into
Monitor.Enter(object);
try
{
//code
}
finally
{
Monitor.Exit(object);
}
See the MSIL of the assembly.
We can write much more code and perform customization in the try block.

316 How can you write to a File System?
     1.   MemoryStream
     2.   BufferedStream
     3.   FileStream
     4.   None of these

Correct Ans : 3 FileStream: Through FileStream, we can define the path of a File and then write the data, we have to use StreamWriter/BinaryWriter with FileStream.
MemoryStream and BufferedStream write the data only in the RAM.

317 How can you store decimals data precisely from .NET?
     1.   StreamWriter
     2.   XmlTextWriter
     3.   BinaryWriter
     4.   None of these

Correct Ans : 3 BinaryWriter allows us to store decimal data precisely. It has got the appropriate functions for that. StreamWriter and XmlTextWriter write data in ASCII
format.

318 Can you install multiple assemblies together?
Yes, we can install multiple assemblies together
use installutil command
example: installutil Assembly1.exe Assembly2.exe.
It will install both the Assemblies in a transactional manner. if installation of one
of the assemblies fail, the installation of the other assembly will be rolled back.

319 Difference between Assembly.LoadFrom() and Assembly.LoadFile() methods?
Both methods are used to load the assemblies. we can then extract all the metatdata of the assembly using Reflection.
Difference:
1)LoadFrom can use either the name or the path of the assembly,
LoadFile will expect the path of the assembly(see the overloaded versions)
2)LoadFrom uses a probing algorithm to find the assembly.f if you have two assemblies that have the same identity but different locations, you can get some unexpected
behavior.But using LoadFile, you can load the desired assembly as needed.

320 Is MSIL a high/low/middle level language?

MSIL
Microsoft Intermediate Language:
It is a set of CPU independent instructions which represent your code and used to provide language interoperability and compatibility of your code on different
platforms.
It is not a high level language:
High Level language is C#:
High level language is more human readable,closer to a spoken language.
(Example: programming constructs like loops,if else conditions, keywords like using, class)
High level language defines modular programming,OOPS concepts and the source code.
MSIL is not low level language either:
low level language is in an executable or binary format(eg: machine language)
MSIL is not in an executable or binary format.
MSIL is not middle level language too:
Middle level language is C. It has modular programming and source code.
It is human readable.
C also supports low level programming (Assembly Language).

321 Can we use static constructors to initialize non static members?
Yes, it is possible.
But we have to create an object of the class inside the static constructor and then initialize the non static member through the object reference.
Code(example):
class Class2
{
int a;
static Class2()
{
Class2 p = new Class2();
p.a = 45;
System.Console.WriteLine(p.a);
}
static void Main()
{
}
}

322 Which Constructor gets fired first Static or Non­Static while creating an object of a class?
Static constructor will be fired first.
Ex:

    class Test{
               public Test(){
                      Console.WriteLine(" public Test()");



                                                                                                                                                       Page 29 of 49
                }
                static Test(){
                    Console.WriteLine(" static Test()");
                }
        }
        class Program{
                static void Main(string[] args){
                    Test test = new Test();
                    Console.Read();
                }
        }



Output:
static Test()
public Test()

323 Difference between Globalization and Localization ?
Globalization refers to formatting data in formats relevant for the current culture setting.
example:
a)consider this tag in Web.Config file.
<globalization culture="fr­FR"/>
It would cause the dates to be displayed in French for the web page of
the folder where this Web.Config file is located.
b) CultureInfo d=new CultureInfo("de­DE");
Response.Write(DateTime.Now.ToString("D",d);
It would display date in long format using German culture

Localization refers to retrieving and displaying appropriately
localized data based on the culture.
It can be done by using the Resource files.
example:
we have 2 resource files:
a)default.aspx.fr­FR.resx
b)default.aspx.en­US.resx
Using appropriate coding in the .aspx.cs files of a web page, the strings written in these resource files can be used to change the text of the strings dynamically.

324 Which debugging window can be used to view the variables in current and previous statements?
Autos Window is the debugging window that can be used in the condition
mentioned. When in break mode(use F10 key for that),Autos Window can be opened from the
Debug Menu­­>Windows­­>Autos

325 On which of these locations, we cannot create a breakpoint?
   1.   namespace name
   2.   class name
   3.   variable name
   4.   1 and 2

Correct Ans : 4 we cannot create a breakpoint where we define a namespace or a class. we can create a breakpoint where we define a variable.

326 What are listeners?
These are the classes used to collect the output of Tracing.
The listeners write the Tracing output which they collect to a number of devices.
3 Types of listeners are there:
1)TextWriterTraceListener
It allows us to write messages to an object of the TextWriter class.
2)EventLogTraceListener:
It allows us to write messages to EventLogs
3)DefaultTraceListener:
Allows us to send messages to Output Window.
They are defined by System.Diagnostics namespace
example:

  Stream m = File.Create("dd.txt");


  /*Create a TextWriterListener and then add it to the Listeners*/
        TextWriterTraceListener t = new
            TextWriterTraceListener(m);
        Trace.Listeners.Add(t);


        // Write output to the file.
        Trace.Write("hello ");


327 Which of these editors allows us to perform searches on the target machine for a Registry key or Windows Installer components?
   1.   Registry Editor
   2.   Launch Conditions Editor
   3.   Custom Actions Editor
   4.   None of these.

Correct Ans : 2 Launch Conditions Editor is the correct option.It allows us to check the conditions when installation begins on the target machine. Registry Editor is




                                                                                                                                                          Page 30 of 49
incorrect as it allows us to specify Registry keys, subkeys that are added to Registry during installation. Custom Actions Editor allows us to perform actions like running
scripts, DLL's to perform additional tasks.

328 What are merge modules?
Merge modules are a feature of Windows Installer that can be incorporated into the setup projects of various applications and used to perform operations like
installing assemblies in the GAC.Merge modules cannot be installed directly,
They are merged into an installer for each application that uses the component.
Merge modules contain a component such as a .dll along with any related files, resources, registry entries, and setup logic.

329 .NET and Java J2ee Design pattern interview question :­ What is the difference between Template and Strategy pattern?
Below are the main differences between these two design patterns.
Template Design pattern
Defines outline for algorithms and allows sub class to override some steps.
Efficient in terms of less redundant code.
Depends on super class for methods.
Strategy Design pattern
Uses object composition to provide variety of algorithm implementation.
Flexible in terms of allowing users to change algorithm at run time.
All the algorithms can be itself implemented.
Regards,
Do visit our .NET design pattern and Java J2EE design pattern interview questions.

330 How the garbage collector knows when to collect garbage ?
The garbage collector's optimizing engine determines the best time to perform a collection based upon the allocations being made. When the garbage collector
performs a collection, it checks for objects in the managed heap that are no longer being used by the application and performs the necessary operations to reclaim their
memory.

331 What is the difference between ASP.NET and VB.NET?
ASP.Net is a program application with server controls with programmable objects, which can do the same job HTML did in the past. ASP.Net is used to build a Website
and VB.Net is a computer language you use to build the site. Some use VB.Net and others use C# (C Sharp language) to build a website. Using ASP. Net and VB.Net or C#
you can build an E­commerce store, which has multi functional capabilities. You can integrate PayPal or one of the other payment programs into your site. Create an
Email system, speed up the applications by caching the pages and the data within the pages of your site and do a number of other things to successfully run an E­
commerce store on the Internet.
ASP.Net is very successful Web application platform used by individuals and many large companies, who want to build and run their own websites. ASP.Net provides
server controls with the ability to give you rich web content and more. Anyone willing to purchase the software and learn how to properly use this technology can use
the tools, and application system to build a great Website. You can develop and build your own database choosing to use VB.net or C# language. Many websites today,
which were built in the past used HTML language to build their websites.

332 What is an application domain?
An application domain is the CLR equivalent of an operation system’s
process. An application domain is used to isolate applications from one
another. This is the same way an operating system process works. The
separation is required so that applications do not affect one another.
This separation is achieved by making sure than any given unique
virtual address space runs exactly one application and scopes the
resources for the process or application domain using that address space.

333 What is the difference between a strong and weak named assemblies?
1. Weak named assemblies can be duplicated and tampered with, where as strong named assemblies cannot be tampered and duplicated.
2. Strong named assemblies can be copied into GAC(GLOBAL ASSEMBLY CACHE), where as weak named assemblies cannot be copied.
3. A single copy of strong named assembly present in the GAC(GLOBAL ASSEMBLY CACHE) can be shared with multiple applications, where as weak named assembly
must be copied into the bin directory of each project.


Thanks and Regards
Akiii

334 What are the different types of assemblies in .net?
There are two types of assemblies are there in .net. They are,
1. Private Assemblies and
2. Public/Shared Assemblies.
Private Assembly:­ An assembly is used only for a particular application. It is stored in the application's directory other wise in the application's sub directory. There is no
version constraint in private assembly.
Public Assembly:­ It has version constraint. This public assembly is stored inside the global assembly cache or GAC.GAC contains a collection of shared assemblies.

335 How do we read entire contents of a file named MsgSrikanth.txt(Text File Example) into a single string variable ?
There is a text file named "MsgSrikanth.txt" which has contents. Now we can convert that entire text file into a single string variable called showResult.
That conversion is shown below :
In VB.NET

Dim showResult As String = NothingDim reader as New
StreamReader("MsgSrikanth.txt")showResult = reader.ReadToEnd()



In C#.NET

string showResult = NothingDim;
StreamReader reader = new StreamReader("MsgSrikanth.txt");
showResult = reader.ReadToEnd();



ReadToEnd() method used to read content from the current position to the end of the file.

336 What is the difference between app.config, web.config and machine.config ?
In this .NET Interview questions interviewer expects two things. First the importance of configuration and second in which scenarios are the above file applicable. So lets
answer the question in two parts.


The importance of config files
==================================================
App.config, web.config and machine.config are files which store configuration data in XML




                                                                                                                                                             Page 31 of 49
format. We need configuration data at application level or at machine/server level.


Scenarios in which the above config files are used
===================================================
Machine.config file stores configuration information at system level. It can contain configuration information like timeout in ASP.NET application, requestLimit,
memoryLimit, and ClientConnectedCheck etc.


Generally we have two kinds of application web application and windows application. Web.config file stores configuration data for web applications and app.config file
store configuration information for windows application.


Application level configuration data can be like connection strings,security etc.


Some connected questions from this question which the interviewer can ask
================================================================================
Where do you store connectionstring ?.
How do you encrypt connection string?
How do you read configuration data from web.config or app.config file in .NET ?
Can we have two web.config files for a web application.


Regards,




337 .NET Interview questions for Interfaces:­ If A class inherits from multiple interfaces and the interfaces have same method names. How can we provide different
implementation?.
This is again one those typical .NET Interview questions which move around interfaces to confuse the developer.


For providing different implementation you can qualify the method names with interface names as as shown below. A reference to I1 will display "This is I1" and
reference to I2 will display "This is I2". Below is the code snippet for the same.


interface I1
{
void MyMethod();
}



interface I2
{
void MyMethod();
}



class Sample : I1, I2
{
public void I1.MyMethod()

{
Console.WriteLine("This is I1");
}
public void
I2.MyMethod()
{
Console.WriteLine("This is I2");

}
}




50 .NET Interview questions and answers




338 .NET and OOP interview questions :­ What is the difference between abstraction and encapsulation ?
This is a very typical .NET interview question which confuses most of the .NET professionals. Both abstraction and encapsulation look similiar , but they have huge
differences between them.


Abstraction is nothing but simplifying objects while encapsulation is hiding complexity.


Encapsulation implements abstraction. Abstraction is a thought process which happens during planning phase. While encapsulation implements abstraction by using
access modifiers ( private,public, protected,internal and protected internal).




                                                                                                                                                        Page 32 of 49
Regards,



339 SQL Server interview question :­ Select record with the second lowest value from the below customer table?
Below is a simple customer table with 3 fields code , name and amount. Can you select the customer with second lowest amount. This is one of the favorite questions
which is asked to test your SQL Server skills.


Code         Name             Amount
1001         pqr              200.00
1002         raju             100.00
1004         shiv             300.00
1007         shaam            400.00

Below is the answer. It can be accomplished by using sub queries. First select the min and then get all records which are more than the min and select top 1 from the
same. Below goes the query.


select top 1 * from tbl_Customer touter where touter.Amount > (SELECT
min(tinner.Amount)
   FROM [Customer].[dbo].[tbl_Customer] as
tinner)
   order by touter.Amount asc




Some time interviewers can trick you questions like select the second top. In the subquery we just need to change the same to max.




340 c# interview question :­ Why is stringbuilder concatenation more efficient than simple string concatenation?
This question is one of the favorites question which comes during c# interviews and the interviewer is not only expecting which one of them is more efficient. But he is
also expecting the reason for the same.


In order to understand the same better lets consider the below scenario where we have two lines of code which does string concantenation.


For a simple string concantenation code shown below it will create 3 copies of string in memory.




//The below line of code Creates one copy of the string
string str =
"shiv";



/* The below line of             code creates three copies of string object one for
the concatenation            at right hand side and the other for new value at the
left hand side. The first old allocated memory is sent for garbage
collection.*/
str = str + "shiv";




When you use the string builder for concatenation it will create only one copy of the object.




/* The below code uses string builder and only one
object is created as
compared to normal string where we have 3 copies created*/
StringBuilder
objBuilder = new StringBuilder();
objBuilder.Append("shiv");




Ok now summarizing what should we say to the interviewer.


String is immutable. Immutable means once assigned it can not be changed. Thats why it creates more copies of the object as it can not use the same instance.String
builder is mutable , in other words the same object will changed rather than creating new objects.


So string builder is more efficient as compared to simple string concatenation.




                                                                                                                                                       Page 33 of 49
Regards,



341 If you are said to improve .NET code performance what will you do ?
These kind of questions are very generic. Just pick up 5 best tips you know our have implemented and say it before the interviewer. Below goes my 5



   •   Use stringbuilder as compared to normal string concatenation.
   •   Use stored procedure rather than inline sql code.
   •   Use caching for frequently used data.
   •   Use generics collection as compared to simple collection , to avoid boxing / unboxing.
   •   Remove unnecessary boxing and unboxing code.
   •   In case you are using unmanaged code use the dispose final function for clean up.




342 .NET interview question on generics :­ How does performance increase by using generic collection ?
When we use normally .NET collection objects there is lot of boxing and unboxing. When we create a collection which is a generic collection its strongly typed. As its
strongly typed boxing and unboxing gets eliminated and thus increasing performance.




343 ASP.NET interview question:­What is the difference between render and prender event ?
This is again a very nice .NET interview question and the question can be confusing because of the common word "render". Now ASP.NET page has 4 important events.
Init , Load , validate , event and render (Remember SILVER).
Now the final render is a actually a two step process.


1­ First the ASP.NET UI objects are saved in to view state.
2­ loaded viewstate is assembled to create the final HTML.


The first step is pre­render event and the second step is the render event.


Prerender


This is the event in which the objects will be saved to viewstate.This makes the PreRender event the right place for changing properties of controls or changing Control
structure.Once the PreRender phase is done those changes to objects are locked in and the viewstate can not be changed. The PreRender step can be overridden using
OnPreRender event.


Render.


Render event assembles the HTML so that it can be sent to the browser.In Render event developers can write custom HTML and override any HTML which is created till
now.The Render method takes an HtmlTextWriter object as a parameter and uses that to output HTML to be streamed to the browser. Changes can still be made at this
point, but they are reflected to the client only i.e. the end browser.




344 ASP.NET Interview question :­ What are HttpHandler and HttpModules and how do they differ?
Both the above concepts are rarely used by developers but mostly asked in .NET interviews ;­).
The prime and common goal of HttpHandler and httpModule is to inject pre­processing logic before the ASP.NET request reaches the IIS server.


HttpHandler is a extension based processor in other words pre­processing logic is executed depending on file extensions. For instance sometimes you would like to check
that a person should be above age of 18 if he is trying to view any files with extension *.MP4.


HttpModule is event based processor. ASP.NET engine emits out lot of events as the request traverses over the request pipeline. Just to name some events
beginrequest,authorizerequest,authenticaterequest etc. By using HttpModule you can write logic in these events. These logic get executed as the events fire and before
the request reaches IIS server.


So a short answer for the above .NET interview question would be HttpHandler is a extension based processor while HttpModule is a event base processor. Both of them
help to inject pre­processing logic before the ASP.NET request reaches the IIS server.




345 C# Interview questions:­ What role did your play in your current project?
This is again a great c# interview question , but .NET professionals tend to answer this question in one liners like i am a developer , project manager.


In todays world people expect professionals who can do multitasking. The best way to approach the answer is by explaining what things did you do in the complete SDLC
cycle. Below goes my version of the answer , you can tailor the same as per your needs.




                                                                                                                                                           Page 34 of 49
My main role in the project was coding , unit testing and bug fixing. Said and done that i was involved in all phases of the project.
I worked with the business analyst in the requirement phase to gather requirements and was a active member in writing use cases.
I also assisted the technical architect in design phase. In design phase i helped the architect in proof of concept and putting down the technical design document.
My main role was in coding phase where i executed project with proper unit testing.
In system integration test and UAT i was actively involved in bug fixing.


Other than the project i help COE team for any kind of RND and POC work.


In case you are doing some extra activities in the company like helping COE , presales team or any other initative do speak about the same.


346 .NET interview question :­ Who is faster hashtable or dictionary ?
This is again a typical collection .NET interview question. Dictionary is faster than hashtable as dictionary is a generic strong type. Hashtable is slower as it takes object as
data type which leads to boxing and unboxing.
Below goes the same code for hashtable and dictionary.


Hashtable hashtable = new Hashtable();
hashtable[1] =
"One";
hashtable[2] = "Two";
hashtable[13] = "Thirteen";


var dictionary = new Dictionary<string,


int>();
dictionary.Add(i.ToString("00000"),
10);
dictionary.Add(i.ToString("00000"), 11);




347 c# Interview question :­ Can you explain difference between Pascal notation,Camel notation and hungarian notation ?
The above c# interview question is asked to ensure if you have used coding standards in your project. All the above 3 things are nothing but naming conventions which
are followed in programming languages to ensure a clean code. Below is the explanation of each naming convention.


Pascal Notation­ In this naming convention all starting letter of the words are in Upper Case and other characters are lower case.


Example: SupplierCode


Camel Notation­ In this naming convention first character of all words, except the first word are Upper Case and other characters are lower case.


Example: supplierCode


Hungarian notation ­ In this naming convention the variable name starts with group of small letter which indicate data type.


Example: bLoop ( b indicates its a boolean type),iSum ( i indicated its a integer data type).


Regards,


348 .NET Interview question :­ What coding standards did you followed your projects ?
This is a very general .NET interview question.
Normally properly planned companies have a checklist of what kind of naming convention to follow. In .NET interview its very difficult to speak about the whole checklist
as we have limited time.
The expectation of the interviewer is that you should speak about pascal,camel and hungarian naming conventions and where did you use what.So below goes a short
answer.


Our organization had a naming convention document which was supposed to be followed by all projects in the organization. As per the document we where using three
types of naming conventions across the project :­ Pascal , Camel and Hungarian.


All class names , function names , method names , namespace names where using pascal convention. i.e the first letter capital with every first word capital.ex
CustomerCode




                                                                                                                                                             Page 35 of 49
All variables , input/output variable , local variables , class level variable , global variables where using Camel notation. i.e. the first letter small and then the first letter of
the subsequent words capital.ex count , customerData


For the UI obejct we where using hungarian notation. In this the prefix defines the datatypes i.e. txtCode , cmbCountries.


For database we used Hungarian notation where the prefix defines the data base object types. i.e. tblCustomer , uspSelectCustomer,fngetValue,trgInsert.


Regards,



349 c# interview questions :­ What are the benefits of three tier architecture ?
This is a very popular c# interview question.In 3 tier architecture / layer we divide the project in to 3 layers UI , Middle and DAL. Due the modular approach we have 2
big advantages


Reusability :­ You can reuse the middle layer with different user interfaces like ASP.NET , windows etc. You can also reuse you DAL with different projects.


Maintainability :­ When we change in one layer due to the modular approach it does not have ripple effect on other layers. we have to do less amount of changes in
other layer when we change logic of one layer.


Regards,


350 .NET interview questions :­ What is the use of private constructor ?
This is one of those .NET interview question which is asked from the perspective to test if you understand the importance of private constructors in a class.
When we declare a class constructor as private , we can not do 2 things:­

    • We can not create a object of the class.
    • We can not inherit the class.


Now the next question which the interviewer will ask , whats the use of such kind of class which can not be inherited neither instantiated.


Many times we do not want to create instances of certain classes like utility , common routine classes. Rather than calling as shown below



clsCommon common = new clsCommon();
common.CheckDate("1/1/2011");


You would like to call it as


clsCommon.CheckDate("1/1/2011");




351 .NET interview questions :­ Can you explain architecture of your project ?
This is normally the first .NET interview question which pops up in .NET and C# interviews. Personally i think your full .NET interview ahead depends on how you will
answer this question.

Common mistakes :­ Many developers make a common mistake of answering this question by saying that we have used C# , SQL server , ASP.NET etc. But please do note
that the question is, what is the architecture of your project and not technology.

So a typical answer will be something as below. Please note your answer will vary as per your architecture and structure.

"My current architecture is a simple 3 tier architecture with UI in ASP.NET , middle layer are simple .NET classes and DAL is using enterprise application blocks.
The UI is responsible to take user inputs , all my business validations are centrally located in middle layer and the data access layer is responsible to execute stored
procedured and SQL queries to SQL Server.
Strongly typed business objects are used to pass data from one layer to other layer. The database of the project is in a 3rd normal form."
So first start with the overall architecture , talk about each layer , how data is passed between each layer and the database design structure.
One very important tip if you can draw a diagram and explain....I think you have the job.




                                                                                                                                                                  Page 36 of 49
352 C# interview questions :­ In ADO.NET What is connection, command, datareader and dataset object ?
Connection: ­ This object creates a connection to the database. If you want to do any operation on the database you have to first create a connection object.


Command: ­ This object helps us to execute SQL queries against database. Using command object we can execute select, insert, update and delete SQL command.


Data reader: ­ This provides a recordset which can be browsed only in forward direction. It can only be read but not updated. Data reader is good for large number of
records where you want to just browse quickly and display it.


Dataset object: ­ This provides a recordset which can be read back and in forward direction. The recordset can also be updated. Dataset is like a in memory database
with tables, rows and fields.


Data Adapter: ­ This object acts as a bridge between database and dataset; it helps to load the dataset object.




353 .NET interview question video :­what is the difference between convert.tostring() and tostring() functions ?
This is one of those famous .NET interview question which keeps coming up now and then. To answer precisely and shortly convert.tostring handles nulls while simple
tostring() function does not handle null. Below video demonstrates the same practically.


354 C# interview question :­ What is Serialization in .NET ?
Serialization is a process by which we can save the state of the object by converting the object in to stream of bytes.These bytes can then be stored in database, files,
memory etc.

Below is a simple code of serializing the object.



MyObject objObject = new MyObject();


objObject.Value = 100;
// Serialization using SoapFormatter


SoapFormatter formatter = new SoapFormatter();


Stream objFileStream = new FileStream("c:\\MyFile.xml", FileMode.Create, FileAccess.Write, FileShare.None);


formatter.Serialize(objFileStream, objObject);


objFileStream.Close();




Below is simple code which shows how to deserialize an object.



//De-Serialization


Stream objNewFileStream = new FileStream("c:\\MyFile.xml", FileMode.Open, FileAccess.Read, FileShare.Read);


MyObject objObject =(MyObject)formatter.Deserialize(objNewFileStream);


objNewFileStream.Close();




355 ASP.NET Interview questions :­ What is the advantage of using MVC pattern?
MVC is one of the most used architecture pattern in ASP.NET and this is one of those ASP.NET interview question to test that do you really understand the importance of
model view controller.



   •
       It provides a clean separation of concerns between UI and model.

   •
       UI can be unit test thus automating UI testing.

   •
       Better reuse of views and model. You can have multiple views which can point to the same model and also vice versa.




                                                                                                                                                         Page 37 of 49
    •
        Code is better organized.




356 ASP.NET and .NET Interview question video :­ What is Authentication and Authorization ?
Authentication is the process where we identify who the user is.
Authorization is the process where we check what kind of role the identified user has.


357 .NET Interview questions :­ How did you do unit testing in your project?
In today’s software industry people do not just look how good you are in coding but they would like to know how good you are in processes.
This C# interview question touches one of the important aspects of SDLC processes which is “Unit testing” or you can say white box testing.


Note: ­ Many developers answer that they did unit testing manually. Many interviewers of bigger companies will not be pleased with this answer. The whole point about
unit testing is to automate white box testing. The time you say you have done manual testing which means you have done integration testing.


There are two important testing tools which are widely used to do unit test in Microsoft technologies, first is VSTS Unit test and second is NUNIT. So if you have used
one of these tools, do talk about the same. Below is a simple sample answer by a developer who has used VSTS unit test for testing.


“Our project was divided in three layers UI, BO and Data access layer. As a developer I was responsible to write unit test code on the middle layer or the business object.
We used VSTS unit test suite to write our test. So for each important functions and methods of the middle layer stubs where generated by right clicking on the middle
layer functions. Inside the stub we went and put proper assert function as needed by the test”.


Regards,



358 .NET and SQL Server interview question: ­ What is difference between truncate and delete?

Both Truncate and Delete are used to delete data from the tables. Below are some important differences.



    x   TRUNCATE is a DDL (data definition language) statment whereas DELETE is a DML (data manipulation language) statement.




    •   In DELETE command we can use where condition in TRUNCATE you cannot.



    •   TRUNCATED data cannot be rolled back while delete can be.



    •   When there are triggers on table and when you fire truncate trigger do not fire . When you fire delete command triggers are executed.



    •   TRUNCATE resets the identity counter value where DELETE does not.



    •   Delete and Truncate both are logged operation. Delete operation is logged on row basis while TRNCATE logs at page level.



    •   TRUNCATE is faster than DELETE.




Regards,




359 .NET and Java J2ee design pattern interview question :­What is the difference between Object and class adapters?
Below are the main difference between these 2 patterns.


Object adapter
Can adapt classes as well as sub classes since uses composition
More flexible since dynamic polymorphism can be used with composition


Class adapter


Can adapt classes or sub classes not both. As a result no need to re implement the entire adaptee
More efficient since class adapter acts as adapter and adaptee


regards,


360 .NET and Java J2ee Design pattern interview question :­ What is the difference between Decorator and Adapter pattern?
Below is the main difference between these two design patterns.




                                                                                                                                                          Page 38 of 49
Decorator Design pattern


Used to deal with new behavior or responsibilities without affecting existing code.
Provides a wrapper over objects to apply same method which yields different results based on whether the object invoked is granular or composite.
Change of interface does not happen.
Adapter Design pattern
Mainly involved in converting interfaces as per the requirement of client
Allows use of new libraries without changing existing methods
Change of interface happens in this case


Regards,



361 .NET interview questions :­ What are Regex / regular expressions ?
Regex or regular expression helps us describe complex patterns in texts. Once you have described these patterns you can use them to do searching, replacing, extracting
and modifying text data.

Below is a simple sample of regex. The first step is to import the namespace for regular expressions.


 using System.Text.RegularExpressions;




The next thing is to create the regex object with the pattern. The below pattern specifies to search for alphabets between a­z with 10 length.


 Regex obj = new Regex(“[a-z]{10}”);



Finally search the pattern over the data to see if there are matches. In case the pattern is matching the ‘IsMatch’ will return true.


 MessageBox.Show(obj.IsMatch(“shivkoirala”).ToString());


Regards,


362 Design pattern interview questions :­ Which design patterns have you used in your project ?
First thing what ever you say , for heaven sake do not say we had used all design patterns ;­) . Look at your project and see which design pattern have you used. Almost
all projects use design patterns knowingly or unknowingly , until the project is complete disorganized.
While explaining do ensure to make a 1 line comment atleast to say why that design pattern was used.
Below goes a decent answer of explaining things collectively. Please note answer will change as per your project implementation.


In my current project we had used MVC, Singleton, factory , iterator and template pattern.

My project was tier architecture, divided in to 3 main sections, UI, Business layer and data access layer.

At the presentation level we had used MVC pattern, so the UI and model was separated using controller class.

To share common data across all tiers we had used the singleton pattern.

Factory classes where used between each layer for decoupling and centralizing object creation to avoid code complication.

Iterator pattern was used to browse through middle tier objects thus providing a tight encapsulation.

The middle tier objects and their child objects where standardized using template pattern for consistent vocabulary and naming convention for business objects.



Watch the below design pattern video which explains factory pattern.


363 .NET interview questions :­ What is the difference between class and structures ?

1. Classes are reference types and structs are value types. So in other words class will be allocated on a heap and structs will be allocted on the stack.


2. You cannot have instance Field initializers in structs. Example




class MyClass1
{
int myVar =10; // no syntax error.
public void MyFun(
)
{
// statements
}
}




                                                                                                                                                                  Page 39 of 49
struct MyStruct1
{
int myVar = 10; // syntax error.
public void MyFun(
)
{
// statements
}
}




3. Classes can have explicit parameterless constructors. But structs cannot have



4. Classes must be instantiated using the new operator. But structs can be
5. Classes support inheritance.But there is no inheritance for structs.( structs don’t support inheritance polymorphism )
6. Since struct does not support inheritance, access modifier of a member of a struct cannot be protected or protected internal.11. A class is permitted to declare a
destructor.But a struct is not



7. classes are used for complex and large set data. structs are for simple data structures.


Regards,


364 .NET and Java J2ee Design pattern interview question: ­ What is the difference between Template and Strategy pattern
Below are the main differences between these two design patterns: ­


Template Design pattern


Defines outline for algorithms and allows sub class to override some steps.
Efficient in terms of less redundant code.
Depends on super class for methods.


Strategy Design pattern
Uses object composition to provide variety of algorithm implementation.
Flexible in terms of allowing users to change algorithm at run time.
All the algorithms can be itself implemented.


Regards,



365 .NET interview questions: ­ What are the different principle of OOPS?
Different principles of OOPS are Abstraction, Encapsulation, Polymorphism and Inheritance.


1. Abstraction:­ It is a thought process which show only the necessary properties.


2. Encapsulation:­ Hiding complexity of a class.


3. Inheritance:­ Defining a Parent­Child Relationship.


4. Polymorphism:­ Object Changes it's behaviour according to the situation.


Regards,




366 .NET interview questions: ­ What is public, private, protected, internal and internal protected?
In the following manner we can describe the C# access modifiers: ­


public ­ The members (Functions & Variables) declared as public can be accessed from anywhere.


private ­ Private members cannot be accessed from outside the class. This is the default access specifier for a member, i.e if you do not specify an access specifier for a
member (variable or function), it will be considered as private. Therefore, string PhoneNumber; is equivalent to private string PhoneNumber;




                                                                                                                                                          Page 40 of 49
protected ­ Protected members can be accessed only from the child classes.


internal ­ it can be accessed only within the same assembly.


internal Protected ­ internal protected can be accessed within the same assembly as well as in derived class.


Regards,


367 .NET and C# interview question ­ What are the various questions asked in C# and .NET interview?
The following are the 4 basics section for the interview purpose and below is the diagram to understand in better manner.



   •   .NET basics
   •   New Technologies
   •   Architecture
   •   Process




.NET basics include the questions on the following sections.



   • Basics of .NET
   • OOPS
   •   SQL Server
   •   ADO.NET
   •   ASP.NET
   •   Web Services


New Technologies includes the questions on the following sections.



   •   WCF
   •   WPF/Silverlight
   •   LINQ/Entity framework
   •   Azure
   •   WWF


Architecture includes the questions on the following sections.



   •   Design Patterns
   •   MVC MVP MVVM
   •   UML
   •   Documentation
   •   Requirement to design


Process includes the questions on the following sections.



   •   Agile Estimation
   •   FPA
   •   CMMI
   •   Six Sigma


.NET basics


Following questions are related to fundamentals of .NET.



   •   What is CLR, CTS, CTS, IL Code?
   •   What is Value type, Reference type and Stack, Heap Memory?
   •   What is Garbage Collector and working of Garbage Collector?
   •   What are GAC, Delegate, Event, and JIT?




                                                                                                                            Page 41 of 49
Following questions are related to object oriented programming system (OOPS).



   •   Why we need OOPS concept?
   •   What are the different Principals of OOPS?
   •   How to implement Abstraction, Encapsulation, Inheritance and Polymorphism?
   •   What are Abstract Class and Interface and differences? What are the Classes and Object?


Following questionsis related toSQL Server.



   •   What are SQL Queries, Sub Queries?
   •   What are Joins and its different types?
   •   What are Normalization, Denormalization and Performance Tuning?
   •   What are Indexes, Clustered Indexes?


Following questions is related to ADO.NET.



   • What are Dataset, Data Reader and Data Adapter?
   • What are Connection Object and Connection String?


Following questions is related to ASP.NET.



   •   What are the Session Variable, Application and Cache Object?
   •   What isServer.Transfer and Response.Redirect?
   •   Difference between Server.Transfer and Response.Redirect?
   •   What is Authentication and Authorization?


Following questions is related to Web Services.



   • What is WSDL?
   • What are ASMX, SOAP?


New Technologies


Following questions is related to WCF.



   •   What are Operation Contract, Service Contract and Data Contract?
   •   What is Data Member?
   •   What are Address Binding and Contract Binding?
   •   What do you mean End points?


Following questions is related toWPF/Silverlight.



   • What are XAML, XAP?
   • What is Silverlight Architecture?
   • What is MVVM pattern and RIA Services.


Following questions is related toLINQ/Entity framework.



   •   What are the three main components on LINQ?
   •   What is the use LINQ and Entity Framework?
   •   What are Data Context Object and Entity Object?
   •   What are LINQ DBML and LINQ EDMX?


Following questions is related toAzure.



   • What is Cloud Computing?
   • What are blobs, tables and Queues?


Following questions is related toWWF.




                                                                                                 Page 42 of 49
   • What areSequential Workflow and State Machine Workflow?


Architecture


Following questions is related to Design Pattern.



   • What is Factory Design Pattern?
   • What areSingleton Design Pattern and Iterator?


Following questions is related to MVC, MVP and MVVM.



   • Define MVC, MVP and MVVM?
   • What is MVC template and when to use?


Following questions is related toUML.



   • What are Use cases?
   • What is Activity diagram and Class diagram?


Following questions is related toDocumentation.



   • What areRequirement document and Design document?
   • What is test plan?
Following questions is related toRequirement Design.

   • How will you go from Requirement to Design?


Process


Following questions is related toAgile.



   • What are Scrum Backlog Template and Simple Backlog Template?


Following questions is related toEstimation FPA.



   • What are EI, EO, EQ and EIF?


Following questions is related toCMMI.



   • What is meant by Key Process Area (KPA)?
   • What are the different five level of CMMI?


Following questions is related toSix Sigma.



   • What is Six Sigma?
   • What is the importance’s of Six Sigma?
   • What are Six Sigma Yellow Belt and Black Belt?


Regards,


368 .NET interview question ­ What is Shadowing?
Shadowing is a concept of altering the behaviour of the base class member. It basically replaces complete element of the parent class like method becomes a variable.


For example: In the below example in class1 'i' is declared as variable whereas in class2 'i' is declared as a method.

class Program




                                                                                                                                                     Page 43 of 49
        {
              static void Main(string[] args)
              {
                    class1 obj = new class1();
                    class2 obj1 = new class2();
                    obj1.i();                              //here i is treated as method
                    Console.WriteLine(obj.i); //here i is treated as variable
                    Console.ReadLine();
              }
        }
        class class1
        {
              public int i=2;
        }
        class class2 : class1
        {
              public void i()
              {
                    Console.WriteLine("Hello World");
              }
        }



Regards,


369 .NET and Java J2EE Design pattern interview question: ­ What is the difference between Facade and Mediator pattern?
Facade Design pattern



   1.
        Aims at simplifying interface.

   2.
        Existence of façade is not known to sub­system.

   3.
        Intermediates between client and sub stem.



Mediator Design pattern



   1.
        Aims at simplifying object interaction.

   2.
        Existence of mediator is known to objects since they interact using the same.

   3.
        Intermediates between various objects which want to interact.



Regards,



370 .NET/ASP.NET interview Questions ­ How will you do code review using FxCop in .NET?
FxCop is a code analyzer tool which runs on .NET dll file it helps you to analyze the quality of .NET code. (Quality in terms of coding standards, best practices etc.)
To view how exactly the FxCop do code review you need to download the FxCop from MSDN site and install it on your local host machine.
As FxCop runs on .NET dll file you need to add the dll file of your project on which you want to do code review.
The below diagram will give you an idea of how will you add the dll file in FxCop.




Once you click on the Add Target button just browse to the dll file you want to do code review like below diagram.




                                                                                                                                                            Page 44 of 49
After adding the dll file to FxCop, Now click on the Analze button and you will see the window like below diagram with the respective result.




Once you click on analyze button it runs all the rules on the selected dll file and shows that what kind of rules are broken by the dll file.As you see in the above diagram
some of the rules are broken by the selected dll file.
You can take these rules and try to close your project structure in standard manner and improve the quality of your project.


Regards,


371 .NET/ASP.NET Interview Question ­ How will you do Unit Testing using Nunit?
Unit testing is validation and verification technology where the developer tests the individual units of source code. These individual units can be functions, methods or
class.
Below is the simple Math class which has a Add function with two input parameter. The Add function basically adds the number and gives the addition of these two
numbers.
As a developer we would like to test is this Add function actually works properly or not .

namespace NunitTest
{
    public class Math
    {
        public int Add(int i, int j)
        {
            int sum;
            sum = i + j;
            return sum;
        }
    }
}

In order to do unit testing by using Nunit the first thing you need to create a simple CheckNunit class as shown in the code below.

namespace CheckNunit
{
    [TestFixture]
    public class NunitTest
    {
        [Test]//it is called as attribute
        public void check()
        {
            Math obj = new Math();
            int result = obj.Add(10, 20);
            Assert.AreEqual(30, result);
        }
    }
}




                                                                                                                                                          Page 45 of 49
In NunitTest class the check function is attributed by the Test.it is saying that we are passing 10 and 20 value and we are expecting the result as 30.if the result is 30 then
everything is working properly else there is something wrong in the code.
Once you have completed the above steps, Open Nunit software and select the .dll file of CheckNunit like the following diagrams.




Now click on run button and see the respective output. If it displays green color then everything is working fine and if it displays red color then there is something wrong
in code. The following two diagram will give you an better idea.




Let inject a small defect, so that we can check how Nunit display the result.
Now I change the Addition(+) sign as Multiplication(*) sign so the method fail to add values and Nunit displays Red signal like below diagram.




Regards,

372 .NET/ASP.NET Interview Question ­ How will you do Unit Testing using VSTS?
Unit testing is validation and verification technology where the developer tests the individual units of source code. These individual units can be functions, methods or
class.


Below is the simple Math class which has a Add function with two input parameter. The Add function basically adds the number and gives the addition of these two
numbers.


As a developer we would like to test is this Add function actually works properly or not.


namespace TestVSTS
{
public class Math
     {
public int Add(int i, int j)
           {
               int sum;
               sum = i + j;




                                                                                                                                                            Page 46 of 49
              return sum;
         }
     }
}




In order to do unit testing by using VSTS the first thing you need to create a simple unit test. In visual studio team system (VSTS)they provide the test menu in which you
can select the unit testing as you can see in the below diagrams.




After selecting unit test open the .cs file and write the logic in [TestMethod] attribute which you want to test.


[TestMethod]
public void Check()
         {
         Math obj = new Math();
         int r = obj.Calculate(10,20);
         Assert.AreEqual(30,r);
         }




Once you have completed the above steps, now set unit test project as startup project, and run the application.
If the function work properly it will gives us Passed result as you see in below diagram.




If the Unit test gives us Failed result it means something wrong in function as you see in the below diagram.




373 .NET and C# interview questions: How to view a .NET assembly?
When coming to understand the internals, nothing can beat ILDASM. ILDASM converts the whole ‘exe’ or ‘dll’ in to IL code. To run ILDASM you have to go to ‘C:\Program
Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin’. Note that we had v1.1 you have to probably change it depending on the type of framework version you have.




                                                                                                                                                        Page 47 of 49
If you run IDASM.EXE from the path you will be popped with the IDASM exe program as shown in figure. Click on file and browse to the respective directory for the DLL
whose assembly you want to view. After you select the DLL you will be popped with a tree view details of the DLL as shown in figure ILDASM. On double clicking on
manifest, you will be able to view details of assembly, internal IL code etc as shown in the figure.

Note: - The version number are in the manifest itself which is defined with the DLL or EXE thus
making deployment much easier as compared to COM where the information was stored in registry.
Note the version information in Figure Manifest view.



You can expand the tree for detail information regarding the DLL like methods, properties, functions etc.




And once you open the Manifest you will be able to see the inner details as shown in the following picture: ­




374 C# and .NET interview questions: What is an interface?
Interface is a contract that defines the signature of the functionality. So if a class is implementing a interface it says to the outer world, that it provides specific behavior.
Example if a class is implementing ‘Idisposable’ interface that means it has a functionality to release unmanaged resources. Now external objects using this class know
that it has contract by which it can dispose unused unmanaged objects.
   • Single Class can implement multiple interfaces.
   • If a class implements a interface then it has to provide implementation to all its methods.


Following code shows that one has the interface definition and other class implements the interface. Below is the source code “IInterface” is the interface and
“ClsDosomething” implements the “IInterface”. This sample just displays a simple message box.

Public Interface IInterFace
Sub Do Something ()
End Interface


Public Class ClsDoSomething
Implements IInterFace
Public Sub DoSomething () Implements WindowsInterFace.IInterFace.DoSomething
MsgBox (“Interface implemented”)
End Sub
End Class




                                                                                                                                                               Page 48 of 49
After implementing the above code you will get the following output as shown:




                                                                                Page 49 of 49

								
To top