dot net interview questions -17

dot net interview questions -17

1.What is an Application Domain?

An AppDomain can be thought of as a lightweight process. Multiple AppDomains can exist inside a Win32 process. The primary purpose of the AppDomain is to isolate an application from other applications.
Win32 processes provide isolation by having distinct memory address spaces. This is effective, but it is expensive and doesn't scale well. The .NET runtime enforces AppDomain isolation by keeping control over the use of memory - all memory in the AppDomain is managed by the .NET runtime, so the runtime can ensure that AppDomains do not access each other's memory.

2.What is the difference between a private assembly and a shared assembly?

· 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.
· Versioning: The runtime enforces versioning constraints only on shared assemblies, not on private assemblies.

3.How do assemblies find each other?

By searching directory paths. There are several factors, which can affect the path (such as the AppDomain host, and application configuration files), but for private assemblies the search path is normally the application's directory and its sub-directories. For shared assemblies, the search path is normally same as the private assembly path plus the shared assembly cache.

4.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.
Remember: versioning is only applied to shared assemblies, not private assemblies.

5.What is IL?

IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code (of any language) is compiled to IL. The IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler.

6.Does .NET only apply to people building web-sites?

No. If you write any Windows software (using ATL/COM, MFC, VB, or even raw Win32), .NET may offer a viable alternative (or addition) to the way you do things currently. Of course, if you do develop web sites, then .NET has lots to interest you - not least ASP.NET.

7.What platforms does the .NET Framework run on?

The runtime supports Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only supported on Windows XP and Windows 2000. Windows 98/ME cannot be used for development.
IIS is not supported on Windows XP Home Edition, and so cannot be used to host ASP.NET. However, the ASP.NET Web Matrix web server does run on XP Home.
The Mono project is attempting to implement the .NET framework on Linux.

8.What languages does the .NET Framework support?

MS provides compilers for C#, C++, VB and JScript. Other vendors have announced that they intend to develop .NET compilers for languages such as COBOL, Eiffel, Perl, Smalltalk and Python.

9. Will the .NET Framework go through a standardisation process?

From http://msdn.microsoft.com/net/ecma/: "On December 13, 2001, the ECMA General Assembly ratified the C# and common language infrastructure (CLI) specifications into international standards. The ECMA standards will be known as ECMA-334 (C#) and ECMA-335 (the CLI)."

10.How do assemblies find each other?

By searching directory paths. There are several factors, which can affect the path (such as the AppDomain host, and application configuration files), but for private assemblies the search path is normally the application's directory and its sub-directories. For shared assemblies, the search path is normally same as the private assembly path plus the shared assembly cache.

11.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.

12.What is C#?

C# is a new language designed by Microsoft to work with the .NET framework. "C# is a simple, modern, object oriented, and type-safe programming language derived from C and C++. C# (pronounced “C sharp”) is firmly planted in the C and C++ family tree of languages, and will immediately be familiar to C and C++ programmers. C# aims to combine the high productivity of Visual Basic and the raw power of C++."

13.What are attributes?

There are at least two types of .NET attribute. The first type I will refer to as a metadata attribute - it allows some data to be attached to a class or method. This data becomes part of the metadata for the class, and (like other class metadata) can be accessed via reflection.
The other type of attribute is a context attribute. Context attributes use a similar syntax to metadata attributes but they are fundamentally different. Context attributes provide an interception mechanism whereby instance activation and method calls can be
pre- and/or post-processed.

14.82.What is garbage collection?

Garbage collection is a system whereby a run-time component takes responsibility for managing the lifetime of objects and the heap memory that they occupy. This concept is not new to .NET - Java and many other languages/runtimes have used garbage collection for some time.

15.Why doesn't the .NET runtime offer deterministic destruction?

Because of the garbage collection algorithm. The .NET garbage collector works by periodically running through a list of all the objects that are currently being referenced by an application. All the objects that it doesn't find during this search are ready to be destroyed and the memory reclaimed. The implication of this algorithm is that the runtime doesn't get notified immediately when the final reference on an object goes away - it only finds out during the next sweep of the heap.
Futhermore, this type of algorithm works best by performing the garbage collection sweep as rarely as possible. Normally heap exhaustion is the trigger for a collection sweep.

16.Is the lack of deterministic destruction in .NET a problem?

It's certainly an issue that affects component design. If you have objects that maintain expensive or scarce resources (e.g. database locks), you need to provide some way for the client to tell the object to release the resource when it is done. Microsoft recommend that you provide a method called Dispose() for this purpose. However, this causes problems for distributed objects - in a distributed system who calls the Dispose() method? Some form of reference-counting or ownership-management mechanism is needed to handle distributed objects - unfortunately the runtime offers no help with this.

17.What is serialization?

Serialization is the process of converting an object into a stream of bytes. Deserialization is the opposite process of creating an object from a stream of bytes. Serialization / Deserialization is mostly used to transport objects (e.g. during remoting), or to persist
objects (e.g. to a file or database).

18.Why string are 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.

19.What does assert() method do?

In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.

20.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.

21.Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.

22.Where is the output of TextWriterTraceListener redirected?

To the Console or a text file depending on the parameter passed to the constructor.

23.How do assemblies find each other?

By searching directory paths. There are several factors which can affect the path (such as the AppDomain host, and application configuration files), but for private assemblies the search path is normally the application's directory and its sub-directories. For shared assemblies, the search path is normally same as the private assembly path plus the shared assembly cache.

24.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.

25.What is a formatter?

A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end.

26.Choosing between HTTP and TCP for protocols and Binary and SOAP for formatters, what are the trade-offs?

Binary over TCP is the most effiecient, SOAP over HTTP is the most interoperable.

27.How can you automatically generate interface for the remotable object in .NET with Microsoft tools?

Use the Soapsuds tool.

28.What is reflection?

All .NET compilers produce metadata about the types defined in the modules they produce. This metadata is packaged along with the module (modules in turn are packaged together in assemblies), and can be accessed by a mechanism called reflection. The System.Reflection namespace contains classes that can be used to interrogate the types for a module/assembly.
Using reflection to access .NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and it is used for similar purposes - e.g. determining data type sizes for marshaling data across context/process/machine boundaries.
Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember ) , or even create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder).

29.What do you mean by authentication and authorization?

Authentication is the process of validating a user on the credentials (username and password) and authorization performs after authentication. After Authentication a user will be verified for performing the various tasks, It access is limited it is known as authorization.

30.What's the difference between Response.Write() andResponse.Output.Write()?

The latter one allows you to write formattedoutput.

31.What methods are fired during the page load? Init()

When the page is instantiated, Load() - when the page is loaded into server memory,PreRender () - the brief moment before the page is displayed to the user as HTML, Unload() - when page finishes loading.

32.Where does the Web page belong in the .NET Framework class hierarchy?

System.Web.UI.Page

33.Where do you store the information about the user's locale?

System.Web.UI.Page.Culture

34.What's the difference between Codebehind="MyCode.aspx.cs" and Src="MyCode.aspx.cs"?

CodeBehind is relevant to Visual Studio.NET only.

35.What's a bubbled event?

When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents. Suppose you want a certain ASP.NET function executed on MouseOver over a certain button.

36.Where do you add an event handler?

It's the Attributesproperty, the Add function inside that property.
e.g. btnSubmit.Attributes.Add("onMouseOver","someClientCode();")

37.What data type does the RangeValidator control support?

Integer,String and Date.

38. What are the validation controls?

A set of server controls included with ASP.NET that test user input in HTML and Web server controls for programmer-defined requirements. Validation controls perform input checking in server code. If the user is working with a browser that supports DHTML, the validation controls can also perform validation using client script.

40.Explain the difference between Globalization and Localization.

Globalization refers to the application of culture-specific format to existing data. Localization refers to providing new culture-specific resources and retrieving the appropriate resources based on the culture setting.

41.Explain how to use the PrintPreviewDialog control to display a preview of a printed document before it is printed.

You display a preview of a printed document with the PrintPreviewDialog control by first setting the PrintDocument property of the PrintPreviewDialog instance to the PrintDocument you want to preview, then by calling the PrintPreviewDialog.Show command to display the dialog box.

42.What are the different approaches to testing?
   
There are two different approaches to testing: the waterfall approach and the evolutionary approach.

43. Explain the waterfall approach.
   
The waterfall approach is a traditional approach in which each developer in the development team works in phases. These phases cover requirement analysis, design and specifications requirements, coding, final testing, and release.

44. Explain the evolutionary approach.
   
In the evolutionary approach, you develop a modular piece or unit of application, test it, fix it, and then add another small piece that adds functionality. You then test the two units as an integrated component, increasing the complexity as you proceed.

45.How does the Visual Studio .NET debugger work?
   
When you debug a Visual Studio .NET application, the debugger first maps the native code to MSIL, and then maps the MSIL code to source code by using a PDB file.

46.What are the main windows and dialog boxes that you use to debug a Visual Studio .NET application?
   
The main windows and dialog boxes that you use to debug a Visual Studio .NET application are the Visual Studio .NET debugger window, Breakpoints window, Watch window, Call Stack window, Locals window, Autos window, and Processes window.

47.What is code instrumentation?
   
Code instrumentation is a set of tasks that you perform to monitor and analyze information about the performance of your applications. It involves activities such as writing tracing code for the application, collecting trace information, analyzing the trace output, and troubleshooting the problems that occur at run time.

48.How do you implement code instrumentation?
   
You can implement code instrumentation by using tracing, debugging, performance counters, and event logs.

49.Which tool do you need to use to convert .txt files to .resources files?
   
If you have text files as resources, then you can use the ResGen.exe tool to convert .txt files to .resources files. The syntax for using the ResGen.exe tool is
ResGen strings.txt myResources.resource

50.Which tool do you need to use to compile the .resources files into satellite assemblies?
   
Once you have created .resources files, you can compile them into satellite assemblies by using Al.exe, the Assembly Linker (AL) tool. The AL tool creates satellite assemblies from the .resources files that you specify. As you know, satellite assemblies cannot contain any executable code and can contain only resources.
The following command shows you how to use the Al.exe tool to generate a satellite assembly:
al /t:lib /embed:myResource.resources /culture:de /out:MyRes.resources.dll

51. What is the format of the assembly version stored in the AssemblyInfo file?
   
The assembly version number is a four-part number. The format of the version number is
<\major version>.<minor version>.<build number>.<revision>

52.Which attribute do you use to specify the version number of an assembly?
   
You use the AssemblyVersion() attribute to specify the version of an assembly.

53. What type of Setup project do you create to deploy XML Web services?
     
To deploy XML Web services, you create a Web Setup project.

54.Which tools does the .NET Framework provide to export types defined in an assembly to a type library?
     
The .NET Framework provides the Type Library Exporter (Tlbexp.exe) to export types defined in an assembly to a type library.

55.Which tool can you use to register managed types with the Windows registry?
     
You can use the Assembly Registration Tool (Regasm.exe) to register managed types with the Windows registry.

56.What is smart navigation in .NET?

The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.

57.What is view state in .NET?

The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on
for a single control

58.What’s SingleCall activation mode used for?

If the server object is instantiated for responding to just one single request, the request should be made in SingleCall mode.

59.What’s Singleton activation mode?

A single object is instantiated regardless of the number of clients accessing it. Lifetime of this object is determined by lifetime lease.

60.How do you define the lease of the object?

By implementing ILease interface when writing the class code.

61.Can you configure a .NET Remoting object via XML file?

Yes, via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings take precedence over machine.config.

62.How do you validate the controls in an ASP .NET page?

Using special validation controls that are meant for validation of any controle.We have Range Validator, Email Validator in .NET to validate any control.

63.Can the validation be done in the server side? Or this can be done only in the Client side?

Client side is done by default. Server side validation is also possible in .NET. We can switch off the client side and server side can be done only in .NET

64.How to manage pagination in a page using .NET?

Using pagination option in DataGrid control is available in .NET. We have to set the number of records for a page, then it takes care of pagination by itself automatically.

65.What is ADO .NET and what is difference between ADO and ADO.NET?

ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch

66.What is Reflection in .NET?

It extends the benefits of metadata by allowing developers to inspect and use it at runtime. For example, dynamically determine all the classes contained in a given assembly and invoke their methods. Reflection provides objects that encapsulate assemblies, modules, and types. You can use reflection to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object. You can then invoke the type's methods or access its fields and properties. Namespace: System.Reflection

67. What is "Common Type System" (CTS) in .NET?

CTS defines all of the basic types that can be used in the .NET Framework and the operations performed on those type.
All this time we have been talking about language interoperability, and .NET Class Framework. None of this is possible without all the language sharing the same data types. What this means is that an int should mean the same in VB, VC++, C# and all other .NET compliant languages. This is achieved through introduction of Common Type System (CTS).

68.What is "Common Language Specification" (CLS) in .NET?

CLS is the collection of the rules and constraints that every language (that seeks to achieve .NET compatibility) must follow. It is a subsection of CTS and it specifies how it shares and extends one another libraries.

69.What are possible implementations of distributed applications in .NET?

.NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in System.Runtime.Remoting and System.Web.Services.

70.What are the consideration in deciding to use .NET Remoting or ASP.NET Web Services?

Remoting is a more efficient communication exchange when you can control both ends of the application involved in the communication process. Web Services provide an open-protocol-based exchange of information. Web Services are best when you need to communicate with an external organization or another (non-.NET) technology.

71. What’s a proxy of the server object in .NET Remoting?

It’s a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the communication between real server object and the client object. This process is also known as marshaling.

72.What are remotable objects in .NET Remoting?

Remotable objects are the objects that can be marshaled across the application domains. You can marshal by value, where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to an existing object is passed.

73.What are channels in .NET Remoting?

Channels represent the objects that transfer the other serialized objects from one application domain to another and from one computer to another, as well as one process to another on the same box. A channel must exist before an object can be transferred.

74.What security measures exist for .NET Remoting in System.Runtime.Remoting?

None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at application or server level.

75.What is a formatter in .NET?

A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end.

76.Choosing between HTTP and TCP for protocols and Binary and SOAP for formatters, what are the trade-offs?

Binary over TCP is the most efficient, SOAP over HTTP is the most interoperable in .NET.

77.How do you trigger the Paint event in System.Drawing?

Invalidate the current form, the OS will take care of repainting. The Update method forces the repaint.

78.With these events, why wouldn’t Microsoft combine Invalidate and Paint, so that you wouldn’t have to tell it to repaint, and then to force it to repaint?

Painting is the slowest thing the OS does, so usually telling it to repaint, but not forcing it allows for the process to take place in the background.

79.How can you assign an RGB color to a System.Drawing.Color object?

Call the static method FromArgb of this class and pass it the RGB values.

80.What class does Icon derive from? Isn’t it just a Bitmap with a wrapper name around it?

No, Icon lives in System.Drawing namespace. It’s not a Bitmap by default, and is treated separately by .NET. However, you can use ToBitmap method to get a valid Bitmap object from a valid Icon object.

81.Before in my VB app I would just load the icons from DLL. How can I load the icons provided by .NET dynamically?

By using System.Drawing.SystemIcons class, for example System.Drawing.SystemIcons.Warning produces an Icon with a warning sign in it.

82.When displaying fonts, what’s the difference between pixels, points and ems?

A pixel is the lowest-resolution dot the computer monitor supports. Its size depends on user’s settings and monitor size. A point is always 1/72 of an inch. An em is the number of pixels that it takes to display the letter M.

83.What’s the use of System.Diagnostics.Process class?

By using System.Diagnostics.Process class, we can provide access to the files which are presented in the local and remote system.
Example: System.Diagnostics.Process(”c:\mlaks\example.txt”) — local file
System.Diagnostics.Process(”http://www.mlaks.com\example.txt”) — remote file

84.What is namespaces?

It is a logical group of related classes and interfaces and that can be used byany language targeting the .net framework.

85.What’s a Windows process?

It’s an application that’s running and had been allocated memory.

86.What are the authentication methods in .NET?

Abstract class: This class has abstract methods (no body). This class cannot be instantiated. One needs to provide the implementation of the methods by overriding them in the derived class. No Multiple Inheritance.
Interfaces: Interface class contains all abstract methods which are public by default. All of these methods must be implemented in the derived class. One can inherit from from more than one interface thus provides for Multiple Inheritance.
re-clarification of object based:
VB6 DOES support polymorphism and interface inheritance. It also supports the “Implements” keyword. What is not supported in vb6 is implementation inheritance.
Also, from above, vb6 DOES “provides access to third-party controls like COM, DCOM ” That is not anything new in .NET.

87.Difference between Class And Interface

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

88.What doesu mean by .NET framework?

The .NET Framework is an environment for building, deploying, and running Web Services and other applications. It consists of three main parts: the Common Language Runtime, the Framework classes, and ASP.NET

89.What is assembly?

It is a single deployable unit that contains all the information abt the implimentation of classes , stuctures and interfaces

90.What’s typical about a Windows process in regards to memory allocation?

Each process is allocated its own block of available RAM space, no process can access another process’ code or data. If the process crashes, it dies alone without taking the entire OS or a bunch of other applications down.

91.Explain what relationship is between a Process, Application Domain, and Application?

Each process is allocated its own block of available RAM space, no process can access another process’ code or data. If the process crashes, it dies alone without taking the entire OS or a bunch of other applications down.
A process is an instance of a running application. An application is an executable on the hard drive or network. There can be numerous processes launched of the same application (5 copies of Word running), but 1 process can run just 1 application.

92.What are possible implementations of distributed applications in .NET?

.NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in System.Runtime.Remoting and System.Web.Services.

93.What are the consideration in deciding to use .NET Remoting or ASP.NET Web Services?

Remoting is a more efficient communication exchange when you can control both ends of the application involved in the communication process. Web Services provide an open-protocol-based exchange of information. Web Services are best when you need to communicate with an external organization or another (non-.NET) technology.

94.What’s a proxy of the server object in .NET Remoting?

It’s a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the communication between real server object and the client object. This process is also known as marshaling.

95.What are remotable objects in .NET Remoting?

Remotable objects are the objects that can be marshaled across the application domains. You can marshal by value, where a deep copy of the object is created and then passed to the receiver. You can also marshal by reference, where just a reference to an existing object is passed.

96.What are channels in .NET Remoting?

Channels represent the objects that transfer the other serialized objects from one application domain to another and from one computer to another, as well as one process to another on the same box. A channel must exist before an object can be transferred.

97.What security measures exist for .NET Remoting in System.Runtime.Remoting?

None. Security should be taken care of at the application level. Cryptography and other security techniques can be applied at application or server level.

98.What is Delegation?

99.A delegate acts like a strongly type function pointer. Delegates can invoke the methods that they reference without making explicit calls to those methods.

Delegate is an entity that is entrusted with the task of representation, assign or passing on information. In code sense, it means a Delegate is entrusted with a Method to report information back to it when a certain task (which the Method expects) is accomplished outside the Method's class.

100.What is smart navigation?

The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.

101.What is view state?

The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control

102.How do you validate the controls in an ASP .NET page?

Using special validation controls that are meant for this. We have Range Validator, Email Validator.

103.Can the validation be done in the server side? Or this can be done only in the Client side?

Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.

104.How to manage pagination in a page?

Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.

105.What is ADO .NET and what is difference between ADO and ADO.NET?

ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.

106. What are tuples?

Tuple is a fixed-size collection that can have elements of either same or different data types. Similar to arrays, a user must have to specify the size of a tuple at the time of declaration. Tuples are allowed to hold up from 1 to 8 elements and if there are more than 8 elements, then the 8th element can be defined as another tuple. Tuples can be specified as parameter or return type of a method.

0 comments:

Post a Comment