Saturday, April 24, 2010

ASP.NET Interview Questions

Few days back I was asked by my employer to prepare some interview questions on and sqlserver for the purpose of written test. I am providing few of the interview questions with answers for the same. Let me know your ideas on the topic.

  1. What is the interface we need to implement in order to create a HTTP Handler
    1. IMyHandler
    2. IHttpHandler
    3. IHttpHandlerFactory
    4. None of the above

  2. What is the fastest way to retrieve data from the database
    1. Use DataTable
    2. Use DataAdapter
    3. Use Dataset
    4. Use DataReader
Reason:Because DataAdapter internally makes use of DataReader class.

  1. What is the correct answer among the following regarding the ViewState
    1. It is used to Create the visibility on the Web pages
    2. It is used to Maintain the State of the User as long as he surf the website
    3. It is used to maintain the state between the subsequent requests within a page
    4. It is used to increase the performance of the web application

  2. When does the Session_Start event in the Global.asax fire,
    1. When a new user starts using the application
    2. When the user logs into the server using the Login.aspx page
    3. When a user requests a secured page
    4. When first user sends a request

  3. There is a Master page called MyApplication.master and a content page called MyContentPage.aspx. When we run the application which of the following events will take place first
    1. Page load event in the MyApplication.master
    2. Page load event in the MyContentPage.aspx
    3. PreInit event in the MyApplication.master
    4. PreInit event in the MyContentPage.aspx
Reason:Because you have the capability to change the master page at run time in the PreInit event of the content page.

  1. You need to execute code conditionally, depending on whether the page is generated in response to a server control event on the same page. How would you check this programmatically?
    1. Page.HasControls
    2. Page.IsCrossPagePostBack
    3. Page.IsPostBack
    4. Page.IsCallback

  2. In which folder you can place the SqlServer Express Edition
    1. App_Data
    2. App_Code
    3. App_Themes
    4. App_LocalResources
App_Data folder is used to store the .mdf files in (Introduced in 2.0).

App_Code folder is used to store the class files in (Introduced in 2.0).

App_Themes is used to store the skins, themes etc (Introduced in 2.0).

App_LocalResources is used to store the resource information in

  1. There is a class called as MyClass in C#. When initializing the class in Using block as,
    MyClass obj = new MyClass();
    //Some Code to follow..
    The above application resulted in error. What could be the reason,

  1. We cannot use "using" block for the Custom classes
  2. MyClass must implement IDisposable interface
  3. The obj must be declared in try, catch block
  4. using block cannot be used in ASP.NET, that is only related to C#
Reason:The using block will call the dispose method automatically when the scope of the using block is ended.

  1. If one has two different web form controls in application and if one wanted to
    know whether the values in the above two different web form control match what
    control must be used.
    1. DataGrid Control
    2. CompareValidator
    3. TextBox Validator
    4. ListView Control

  2. Which of the following denote ways to manage state in an ASP.Net Application?
    1. Session Objects
    2. Application Objects
    3. View State
    4. All of the above

  3. In ASP.NET the < authorization > section contain which of the following
    1. <deny>
    2. <allow>
    3. Both A and B
    4. None of the above

  4. What is the easiest way to handle all the exceptions in a web application
    1. Use try.. catch block for all the methods
    2. Use Error handler at the page level in each page
    3. Use Application level Error handler at Global.asax
    4. Create a section in web.config file that can handle all the errors

  5. What is AJAX?
    1. It is a technology that enables browsers to render information faster than normal way
    2. It is a technology which enables javascript to do high graphics on the web pages
    3. It is a latest version of the Web Services
    4. None of the above

  6. What are the datasource controls available in ASP.NET
    1. SqlDataSource
    2. ObjectDataSource
    3. XmlDataSource

    4. All of the Above

  7. How do you Cache a DataTable
    1. By using Cache object
    2. By saving the DataTable to xml file and keeping in memory
    3. Writing the Page Output Cache attribute on the page control
    4. Creating a user control for a DataTable

  8. Trace and debug classes belong to which Namespace
    1. System.Diagnostics
    2. System.Reflection
    3. System.Data
    4. None of the above

  9. Column mappings belongs to which namespace
    1. System.Data
    2. System.Data.Common
    3. System.Xml
    4. System.Data.Relations
     I will post the remaining ASP.NET Interview questions and Sql Server Interview Question to the blog as soon as possible.