Dot Net Interview questions for 3+ years of experience - Part-5




Q1)What is DLL Hell?
Ans)
DLL Hell: DLL Hell refers to the set of problems while sharing multiple applications under a single common component like Dynamic Link Library(DLL) or a Component Object Model(COM) class.
Simply, it is the problem which occurs while registering the DLL components with a common name.
DOT Net has removed this problem by introducing the concept of versioning.
Versioning: Versioning is a process where, every shared application creates its own version number.
For Example, Let us assume that the version number of the first registered DLL takes as V1.0. And Now, you want to overwrite the first registered DLL by installing another DLL with same name.
Then the version number of the second registered DLL would be taken as V2.0.
By this way we can avoid the conflicts of DLL registration and can overwrite the registered DLLs successfully.
-------------------------------------------------------

2)Can we access from a compiled class?
Ans)
Yes we can access cache from a compiled class. Here is the code to it.
''''''''''''''''''''''''''''''''''''''''
MyVariable=System.Web.HttpContext.Current.Cache("");


'''''''''''''''''''''''''''''''''''''''''
---------------------------------
3)How can we clear total cache of a give page?
Ans)
At times we need to make sure that all the cache which was used must be cleared.

This can be done in many ways here is one of the way using the dictionary object
''''''''''''''''''''''''''''''''''''''''''''''
foreach(DictionaryEntry objClearItem in Cache)

{

//Response.Write (objClearItem .Key.ToString ());

Cache.Remove(objClearItem .Key.ToString () ) ;

}
''''''''''''''''''''''''''''''''''''''''''''''''
-------------------------------------------------
4)Can we implement caching with PDF files?
Ans)
Say our PDF files are on the disk then we should let the IIS to handle it. The reason being the caching done through IIS is much faster than ASP.NET cache.

In IIS the caching done through IIS static file handler.
------------------------------------------------
5)How do we read data from a XML file and display it in a DataGrid ?
Ans)
we can do this by using ReadXML method.

DataSet MyDataset= new DataSet ();

MyDataset.ReadXml (Server.MapPath ("sample.xml"));

MyDataGrid.DataSource =MyDataset;

MyDataGrid.DataBind();
-------------------------------------------------
6)How do we write data from the database to a XML file?
Ans)
we can do that using WriteXml method.
'''''''''''''''''''''''''''''''''''''''
In C#

’Filling the DataSet
ds.WriteXml(Server.MapPath ("sample.xml" ) )


In VB

//Filling the DataSet
ds.WriteXml(Server.MapPath ("sample.xml" ) );
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
-------------------------------------------------------------
7)What is the difference between Abstract Class and Interface?
Ans)
Abstract Class:

a) An abstract class is a special kind of class that cannot be instantiated.
b) It allows the other classes to inherit from it but cannot be instantiated.
c) It is used to carry the same hierarchy or standards for all the subclasses.


Interface:

a) An interface is not a class,but it is an entity and has no implementation.
b) It has only the definition of the methods without the body.


Differences:

1) A class may inherit several interfaces, but inherit only one abstract class.
2) An abstract class cn provide complete code, but interface provides just the signature.
3) An abstract class can contain access modifiers for the subs, functions, properties, but an interface cannot.
4) An abstract class defines the core identity of a class, but interfaces are used to define the peripheral abilities of a class.
5) An abstract class is fast whereas the interfaces requires more time to find the actual method in the corresponding classes.
6) If we add a new method to an abstract class, there we can provide the default implementation and therefore all the existing code might work properly whereas in interface, we have to track down all the implementations of the interface and define implementation for the new method.
7) In Interface, we cannot define the fields whereas in an Abstract class, we can define the fields and constants.