Saturday, May 8, 2010

Must learn questions of dotnet


Basic .NET Framework
1. What is an IL?
(IL)Intermediate Language is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code is compiled to IL. 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.

2. What is a CLR?
Full form of CLR is Common Language Runtime and it forms the heart of the .NET framework.All Languages have runtime and it is the responsibility of the runtime to take care of the code execution of the program. For example, VC++ has MSCRT40.DLL, VB6 has MSVBVM60.DLL,and Java has Java Virtual Machine etc. Similarly, .NET has CLR. Following are the responsibilities of CLR

Garbage Collection: - CLR automatically manages memory thus eliminating memory leaks. When objects are not referred, GC automatically releases those memories thus providing efficient memory management.
• Code Access Security: -
• Code Verification: -
• IL (Intermediate language)-to-native translators and optimizer’s:-

3. What is CTS?
In order that two language communicate smoothly CLR has CTS (Common Type System).Example in VB you have “Integer” and in C++ you have “long” these datatypes are not compatible so the interfacing between them is very complicated. In order that these two different languages communicate Microsoft introduced Common Type System. So “Integer” data type in VB6 and “int” data type in C++ will convert it to System.int32, which is data type of CTS. CLS,which is covered in the coming question, is subset of CTS.

4. What is a CLS?

This is a subset of the CTS, which all .NET languages are expected to support. It was always a dream of Microsoft to unite all different languages in to one umbrella and CLS is one-step towards that. Microsoft has defined CLS, which are nothing but guidelines, that language should follow so that it can communicate with other .NET languages in a seamless manner.

5. What is a Managed Code?
Managed code runs inside the environment of CLR i.e. .NET runtime. In short, all IL are managed code. However, if you are using some third party software example VB6 or VC++ component they are unmanaged code, as .NET runtime (CLR) does not have control over the source code execution of these languages.

6. What is an Assembly?
An assembly is the primary building block of a .NET application and can take the form of a dynamic link library (DLL) or executable file (EXE). An assembly is a collection of functionality that is built, versioned, and deployed as a single implementation unit.

A .NET assembly may contain the following elements:
Assembly Manifest – Metadata that describes the assembly and its contents (see below)
Source Code – Compiled into Microsoft intermediate language (MSIL)
Type Metadata – Defines all types, their properties and methods, and most importantly, public types exported from this assembly
Resources – Icons, images, text strings and other resources

7. What are the different types of Assembly?
There are two types of assembly Private and Public assembly. 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. Crystal report classes that will be used by all application for Reports.

8. What is Namespace?
Namespaces allow to group entities like classes, objects and functions under a name. System is the basic namespace used by every .NET code. If we can explore the System namespace little bit, we can see it has lot of namespace user the system namespace. For example, System.Io, System.Net, System.Collections, System.Threading, etc.

9. What is GAC?
GAC (Global Assembly Cache) is where all shared .NET assembly reside. GAC is used in the following situations:-
• If the application has to be shared among several application.
• If the assembly has some special security, requirements like only administrators can remove the assembly. If the assembly is private then a simple delete of assembly the assembly file will remove the assembly.

10. Can we force garbage collector to run?

System.GC.Collect () forces garbage collector to run.

11. What is reflection?
All .NET assemblies have metadata information stored about the types defined in modules. This metadata information can be accessed by mechanism called as “Reflection”. System. Reflection can be used to browse through the metadata information.

12. What are Value types and Reference types?
Value types: -They directly contain data. When you declare an int variable, the system allocates memory to store the value.
Reference type: -The reference types do not maintain data but they contain a reference to the variables, which are stored in memory. This means that if the value in the memory location is modified by one of the variables, the other variables automatically reflect the changes value

13. What is concept of Boxing and Unboxing?

Boxing converts a value-type to a reference-type, thus storing the object on the heap.
Unboxing converts a reference-type to a value-type, thus storing the value on the stack.


Remoting and Web services

1. What is an application domain?

An Application Domain is a light weight process and provides a logical and physical isolation from another .NET application. This ensures that the Applications can work independent and isolated of each other. An Application Domain is created by the Common Language Runtime (CLR) and it ensures that if one Application Domain crashes or goes down, it does not in any way effect the functioning of another Application Domain. Multiple .NET applications can be executed in one single process by loading these applications in separate Application Domains.The following are the benefits of Application Domains.

· Isolation of code, data and configuration information of one application from another
· A failure in one application will not affect the other

2. What is a Web Service?
The term Web services describes a standardized way of integrating Web-based applications using the XML, SOAP, WSDL and UDDI open standards over an Internet protocol backbone. XML is used to tag the data, SOAP is used to transfer the data, WSDL is used for describing the services available and UDDI is used for listing what services are available.

3. Isolation?

LOW (IIS process):- In this main IIS, process, and ASP.NET application run in same process.So if any one crashes the other is also affected. Example let us say (well this is not possible) I have hosted yahoo, hotmail .amazon and goggle on a single PC. So all application and the IIS process runs on the same process. In case any website crashes, it affects every one.

Medium (Pooled):- In Medium pooled scenario, the IIS, and web application run in different process. Therefore, in this case there are two processes process1 and process2. In process1, the IIS process is running and in process2, we have all Web application running.

High (Isolated):-In high isolated scenario every process is running is there own process. In below figure here are five processes and every one handling individual application. This consumes heavy memory but has highest reliability.

Caching Concepts
1. What is View State?
View state is a built-in structure for automatically retaining values amongst the multiple requests for the same page. The view state is internally maintained as a hidden field on the page but is hashed, providing greater security than developer-implemented hidden fields do.

2. What does the "EnableViewState" property do?
IT keeps the data of the control during post backs. If we turn off the values should not populate during server round trip.

3. What is Caching?

Caching enables you to store the expensive data into Cache object and later retrieve it without doing expensive operations. Caching is a technique of persisting the data in memory for immediate access to requesting program calls. Many in the developer community consider caching as one of the features available to improve performance of Web applications.


OOPS
1. What is a Class?
A class describes all the attributes of objects, as well as the methods that implement the behavior of member objects.

2. What is an Object?
They are instance of classes. It is a basic unit of a system. An object is an entity that has attributes, behavior, and identity.

3. What are abstract classes?
We cannot create an object of abstract class. Abstract classes are similar to interfaces. After declaring an abstract class, it cannot be instantiated on its own, it must be inherited. Abstract class is designed to act as a base class. A class can only implement one abstract class only due non-existence of Multi-inheritance in C#.

Public abstract Animal
{
Public void eat (Food food)
{
// do something with food....
}
Public abstract void makeNoise ();
}
Public Dog extends Animal
{
Public void makeNoise ()
{
System.out.println ("Bark! Bark!") ;
}
}
Public Cow extends Animal
{
Public void makeNoise ()
{
System.out.println ("Moo! Moo!") ;
}
}

4. What is an Interface?

An interface contains only the signatures of methods, delegates or events. An interface is a group of related methods with empty bodies.

Interface Bicycle {
Void changeCadence (int newValue);// wheel revolutions per minute
Void changeGear (int newValue);
Void speedUp (int increment);
Void applyBrakes (int decrement);

Class ACMEBicycle implements Bicycle {
// remainder of this class implemented as before
}

5. What is difference between abstract classes and interfaces?
•Abstract classes can have concrete methods while interfaces have no methods
implemented.
• Interfaces do not come in inheriting chain, while abstract classes come in
inheritance.
• You can only inherit one base class, but you can implement multiple interfaces
• Interfaces can only define the API (method signatures, event declarations, property declarations), not the implementation (fields, method bodies, etc)

6. What is a delegate?
A delegate can be defined as a type safe function pointer. You use delegates to call the methods of other objects. A delegate actually stores the address of a method that is contained in some other class. So, a delegate is really the equivalent of a function pointer in C++.

A delegate is basically a reference to a method. A delegate can be passed like any other variable. This allows the method to be called anonymously, without calling the method directly.

In C#, delegates are the basis for events.
For example: A object can create a delegate that refers to one of its private methods. Then the object can pass that delegate to another object. The second object could then call that private method without knowing anything about it (loose-binding).

7. What are Events?
Events are the actions of the system on user manipulations (e.g. mouse clicks, key press etc.) or any event triggered by the program.

An event is basically a list of delegates. Technically, it is a multicast delegate. However, the event keyword allows the compiler to encapsulate the delegate to control how it is accessed.

The object that has the event is called the publisher. The object that handles the event is called the subscriber. An event allows a publisher to call a subscriber's event handler without knowing anything about the subscriber.

For example, a Button object with a Click event can call all the ClickEventHandlers without knowing the class or method names which handle the event.

It is the subscriber's responsibility to subscribe to the event. The publisher simply raises the event at the appropraite time. Whenever the event is raised, each delegate that is in the event's list will be called.

8. What is the difference between delegate and events?
• Actually, events use delegates in bottom. But they add an extra layer on the delegates,thus forming the publisher and subscriber model.
• As delegates are function to pointers, they can move across any clients. So any of the clients can add or remove events, which can be confusing. But events give the extra protection by adding the layer and making it a publisher and subscriber model.

An event offers more restricted access than a delegate. When an event is public, other classes are only able to add or remove handlers for that event: such classes cannot—necessarily—fire the event, locate all the handlers for it, or remove handlers of which they are unaware.

Further, events are more flexibile in terms of how handlers are stored.

9. Can you prevent a class from overriding?
If you define a class as “Sealed” in C

10. What does virtual keyword mean?
They signify that method and property can be overridden.

11. Differentiate Dispose and Finalize.
Dispose method is used to release unmanaged resources when unmanaged resources are no longer in use and referenced and is manually called by the programmer

Finalize is called by the Garbage Collector, and the state of manage objects cannot be guaranteed, so we cannot reference them. Also, we cannot determine when the GC will run, and which objects it will Finalize.

Dispose is called by the programmer, and is used to dispose of managed and unmanaged objects. Within we dispose method, we release all of our resources and call GC.SuppressFinalize as we have done the work of the GC.

12. What is the use of “Overrides” and “Overridable” keywords?
Overridable is used in parent class to indicate that a method can be overridden. Overrides is used in the child class to indicate that you are overriding a method

13. What is Array List?
Array is whose size can increase and decrease dynamically. Array list can hold item of different types. As Array list can increase and decrease size dynamically you do not have to use the REDIM keyword. You can access any item in array using the INDEX value of the array position.

14. What is a Hash Table?
You can access array using INDEX value of array, but how many times you know the real value of index. Hashtable provides way of accessing the index using a user identified KEY value, thus removing the INDEX problem.

15. What are queues and stacks?
Queue is for first-in, first-out (FIFO) structures. Stack is for last in, first-out (LIFO) structures.

16. What is ENUM?
It is used to define constants.


ASP.NET

1. What’ is the sequence in which ASP.NET events are processed?
• Page_Init.
• Page Load.
• Control events
• Page- Unload event.

2. What is event bubbling?
Event Bubbling is nothing but events raised by child controls is handled by the parent control.Server Controls like DataGrid,DataGridView , DataList etc have other controls inside them. Example an DataGridView can have an TextBox or an button inside it. These Child Controls cannot raize events by themselves,but they pass the event to the parent control (DataGridView), which is passed to the page as "ItemCommand" event.
This process is known as EventBubling

3. What is AppSetting Section in “Web.Config” file?

Web.config file defines configuration for a web project. Using “AppSetting” section, we can define user-defined values. Example below defined is “Connection String” section, which will be used through out the project for database connection.

4. Where is View State information stored?
In HTML Hidden Fields.

5. Can you explain “AutoPostBack”?
If we want the control to automatically post back in case of any event, we will need to check this attribute as true. Example on a Combo Box change we need to send the event immediately to the server side then set the “AutoPostBack” attribute to true.

6. What is the use of “GLOBAL.ASAX” file?
It allows to execute ASP.NET application level events and setting application-level variables.

7. What is the difference between ‘Server. Transfer’ and ‘response. Redirect’?
‘Response.Redirect’ sends message to the browser saying it to move to some different page,while server. Transfer does not send any message to the browser but rather redirects the user directly from the server itself. So in ‘server.transfer’ there is no round trip while ‘response.redirect’ has a round trip and hence puts a load on server.


NET Architecture

1. What is MVC pattern?

The main purpose using MVC pattern is to decouple the GUI from the Data. It also gives the ability to provide multiple views for the same Data. MVC pattern separates objects in to three important sections:-

• Model: - This section is specially for maintaining data. It is actually where your business logic, querying database, database connection etc. is actually implemented.
• Views: - Displaying all or some portion of data, or probably different view of data. View is responsible for look and feel, Sorting, formatting etc.
• Controller: - They are event-handling section, which affects either the model or the view. Controller responds to the mouse or keyboard input to command model and view to change. Controllers are associated with views. User interaction triggers the events to change the model, which in turn calls some methods of model to update its state to notify other registered views to refresh their display.

2. What is three-tier architecture?
There are three layers when we talk about three-tier architecture:-
User Interface (Client):- This is mostly the windows user interface or the Web interface but this has only the UI part.
Mid layer: - Middle tier provides process management where business logic and rules are executed and can accommodate hundreds of users (as compared to only 100 users with the twotier architecture) by providing functions such as queuing, application execution, and database staging.
Data Access Layer: - This is also termed by the famous acronym "DAL" component. It has mainly the SQL statement which do the database operation part of the job.

3. What is difference between dataset and data reader?
• Data Reader provides forward-only and read-only access to data, while the Dataset object can hold more than one table (in other words more than one row set) from the same data source as well as the relationships between them.
• Dataset is a disconnected architecture while data reader is connected architecture.
• Dataset can persist contents while data reader cannot persist contents, they are forward only.
• However, one of the biggest drawbacks of Dataset is speed. As “Dataset” carry considerable overhead because of relations, multiple table’s etc speed is slower than “Data Reader”.


4. What are major difference between classic ADO and ADO.NET?
• In ADO we have recordset and in ADO.NET we have dataset.
• In recordset we can only have one table. If we want to accommodate more than one tables we need to do inner join and fill the recordset. Dataset can have multiple tables.
• All data persist in XML as compared to classic ADO where data persisted in Binary format also.

5. Web garden ?
A Web garden is configured on a single server by specifying multiple worker processes for an application pool. Web farms use multiple servers for a Web site.

0 comments: