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


1) In Singleton Design Pattern, synchronization is essential ?
Ans) In Singleton Design Pattern , synchronization is essential only for the first time when the instance is to be created. When the instance is created then it becomes an overhead for each request.

public class Singleton

{

private static Singleton uniqueinstance;



private Singleton()

{

}
public static Singleton getinstance()

{

if(uniqueinstance == null)

{

uniqueinstance = new Singleton();

}

return uniqueinstance;

}

}


In the above code, when for the first time getinstance method is called, synchronization is needed. After the first instance is created, we no longer need synchronization.
---------------------------------------------------
2) Tell me the exact difference between IQueryable and IEnumerable interface ?
Ans)
IEnumerable is applicable for in-memory data querying, and in contrast IQueryable allows remote execution, like web service or database querying.
---------------------------------------------------------
3)When a dynamic compilation of a website project is bad ?
Ans)
Dynamic compilation happens for a website project not for a web application project.
If the site is very large, dynamic compilation of a Web site project might take a noticeable amount of time. Dynamic compilation occurs when a request for a site resource is received after an update to the site, and the request that triggers compilation might be delayed while the required resources are compiled. If the delay is unacceptable, you can pre-compile the site. However, then some of the advantages of dynamic compilation are lost.
--------------------------------------------------


Q4)Why the exception handling is important for an application?
Ans)

Exception handling is used to prevent application from unusual errors occurrences at the time of execution. If the exceptions are handled properly, the application will never get terminated abruptly.
-------------------------------------------
Q5)Define Error Events?
Ans)

ASP.NET supports events. When any unhandled exception occurs in an application, an event occurs, that events are called as Error Events.

ASP.NET is having two events to handle exceptions.
• Page_Error: This is page event and is raised when any unhandled exception occur in the page.
• Application_Error: This is application event and is raised for all unhandled exceptions in the ASP.NET application and is implemented in global.asax

The Error events have two methods to handle the exception:
• GetLastError: Returns the last exception that occurred on the server.
• ClearError: This method clear error and thus stop the error to trigger subsequent error event.

Previous questions


Next questions