1) What determines the connection pool that a connection should use?
1. A connection string 2. The identity or credentials of the user opening the connection 3. The database being connected to 4. The connection object used to connect to the database
a. 1, 2
b. 1, 2, 3
c. 1, 3
d. 1, 4
Answer
Explanation
|
ANSWER: 1, 2
Explanation: Connecting with the database is time consuming and resource intensive task. Connection pool is cache that stores connection string. These connection strings can be reused for future requirements.Only connections with the same configuration can be stored in a pool. Connections are divided into pools by connection string and by identity when integrated security is used. Connection pooling removes the overhead of making a new connection.
|
|
2) What are the recommended techniques for enabling connection pooling on for a SQL Server 2000 or SQL Server 2005 database?
1. Setting the OLE DB Services connection string keyword to -4 2. Opening a connection and not explicitly disabling pooling 3. Setting the connection string keyword Pooling = True in the connection string 4. Using the Connection Pooling tab of the ODBC Data Source Administrator dialog Box
a. 1, 2
b. 1, 2, 3
c. 2, 3
d. 1, 4
Answer
Explanation
|
ANSWER: 2, 3
Explanation: For enabling connection pooling on for a SQL Server 2000 or SQL Server 2005 database set pooling = true and should not explicitly disable it.
|
|
3) How do I explicitly turn on connection pooling for an OLE DB data source?
a. By setting the OLE DB Services connection string keyword to 0
b. By setting the OLE DB Services connection string keyword to -4
c. By setting the OLE DB Services connection string keyword to -1
d. By setting the OLE DB Services connection string keyword to -7
Answer
Explanation
|
ANSWER: By setting the OLE DB Services connection string keyword to -1
Explanation: No explanation is available for this question!
|
|
4) What property contains the actual error message returned by SQL Server?
1. SqlException.Source 2. SqlException.Message 3. SqlError.Class 4. SqlError.Message
a. 1, 2
b. 1, 2, 3
c. 1, 3
d. 2, 4
Answer
Explanation
|
ANSWER: 2, 4
Explanation: SqlException.Message and SqlError.Messageproperty contains the actual error message returned by SQL Server.
|
|
5) What is the connection string’s key / value pair for using WindowsAuthentication in SQLServer 2000 and SQL Server 2005?
a. 1, 2
b. 1, 2, 3
c. 2, 3
d. 1, 4
Answer
Explanation
|
ANSWER: 2, 3
Explanation: You can provide yes, no, true, SSPI and false value to Integrated Security property of connection string according to the requirement. If Integrated Security= truethen current Windows account credentials are used for authentication. SSPI is equivalent to specifying True.
|
|
6) What are the Command object property settings to execute a stored procedure?
1. CommandType = Text, CommandText = stored procedure name 2. CommandType= Text, CommandText = SQL syntax to execute the stored procedure 3. CommandType = StoredProcedure, CommandText = SQL syntax to execute the stored procedure 4. CommandType = StoredProcedure, CommandText = stored procedure name
a. 1, 2
b. 1, 2, 3
c. 2, 4
d. 1, 4
Answer
Explanation
|
ANSWER: 2, 4
Explanation: You can execute stored procedure by using Command object. SqlCommandcmd = new SqlCommand(); cmd.Connection = ConnectionString; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "stored procedure name ";
|
|
7) What should you do to access the returned tabular data after starting execution of a command that runs asynchronously? (Choose all that apply.)
1. Call the EndExecuteNonQuerymethod. 2. Call the EndExecuteReadermethod. 3. Wait for the StatementCompletedevent to fire and iterate through the DataReader. 4. Wait for the StatementCompletedevent to fire, call the EndExecuteReadermethod, and then iterate through the DataReader.
a. 1, 2
b. 1, 2, 3
c. 2, 3
d. 2, 4
Answer
Explanation
|
ANSWER: 2, 4
Explanation: No explanation is available for this question!
|
|
8) How do you execute multiple SQL statements using a DataReader?
a. Call the ExecuteReadermethod of two Command objects and assign the results tothe same instance of a DataReader.
b. Call the ExecuteReadermethod of a single Command object twice.
c. Set the Command.CommandTextproperty to multiple SQL statements delimited by a semicolon.
d. Set the Command.CommandTypeproperty to multiple result sets.
Answer
Explanation
|
ANSWER: Set the Command.CommandTextproperty to multiple SQL statements delimited by a semicolon.
Explanation: You can execute more than one SQL statements delimited by a semicolon. For this you have to set the CommandText property of a Command object to multipleSQL statements separated by semicolons (;). After calling the ExecuteReader method, theDataReader will hold the number of result sets equal to the number of SQL statements executed.
Example: String sqlQuery = ”select * from table1; select * from table2”; SqlConnection con = new SqlConnection(connectionString); SqlCommandcmd = new SqlCommand (); Con.Open(); SqlDataReaderdr = cmd.ExecuteReader();
While(dr.read()) { // Process the table1 } Dr.NextResult();
While(dr.read()) { // Process the table2
}
|
|
9) When would you typically use an Input parameter?
1. When the parameter value is created based on user input 2. When the parameter is used to send data from the application to the database 3. When the command is set to execute a statement with a WHERE clause 4. When the parameter value is passed to an INSERT statement
a. 1, 2
b. 1, 2, 3
c. 2, 3
d. 1, 4
Answer
Explanation
|
ANSWER: 2, 3
Explanation: Input parameter is used to send data from the application to the database. You can also use input parameter in where clause. By default the parameter direction is input type. Parameters are created by using Parameter class.
|
|
10) What are the three primary kinds of parameters?
a. Input, Integer, String
b. Integer, String, DateTime
c. int, varchar, nvarchar
d. Input, Output, InputOutput
Answer
Explanation
|
ANSWER: Input, Output, InputOutput
Explanation: There are three types of parameters that you can use in a .NET Framework and those are Input, Output, InputOutput . Parameters are like variables that you can use to pass and return values between your application and a database. The types of parameters are defined by SqlDbTypeenumeration. It contains a list of the types available in SQL Server. These parameter values are pass to SQL statements and stored procedures. SQL Server uses the @ symbol as a prefix to denote parameters. Parameters are Input parameters by default. You can change its direction by using ParameterDirection property.
Example: SqlParameterparaObj = new SqlParameter(); paraObj.ParameterName = "@TotalCost"; paraObj.SqlDbType = SqlDbType.Money;
|
|
11) How do you determine the actual SQL data type of a SqlParameter (the type expected by the SQL Server)?
a. It is the .NET Framework data type in your application that the parameter represents.
b. It is the type of column or data in SQL Server that the command expects.
c. It is the type of column in a DataTablethat it represents.
d. It is any type defined in the SqlDbDataTypeenumeration.
Answer
Explanation
|
ANSWER: It is the type of column or data in SQL Server that the command expects.
Explanation: No explanation is available for this question!
|
|
12) Which of the following is true?
a. DataTable object contain DataRow and DataColoumn objects
b. DataSet and DataTable can be binary serialized
c. DataSet and DataTable can be XML serialized
d. All of the above
Answer
Explanation
|
ANSWER: All of the above
Explanation: A DataTable is an in-memory representation of a single database table that contains DataRow and DataColoumn objects. Serialization is the process of converting an object into a stream of bytes so you can store or transmit the object. Only those objects can be serialized those have SerializableAttribute. There are two types of serialization binary and XML serialization.
|
|
13) If you are using the DataSet and you have to display the data in sorted order what will you do?
a. Use Sort method of DataTable
b. Use Sort method of DataSet
c. Use DataViev object with each sort
d. Use datapaging and sort the data.
Answer
Explanation
|
ANSWER: Use DataViev object with each sort
Explanation: DataView.Sortproperty allow you to sort data. Using a DataView, you can show the data in a table with different sort orders.
Example. In this example our table name is StudentMaster. public partial class Default5 : System.Web.UI.Page { SqlConnection con = new SqlConnection("provide connection string"); SqlDataAdapter da; protected void Page_Load(object sender, EventArgs e) { string query = "select * from StudentMaster"; da = new SqlDataAdapter(query, con); DataSet ds = new DataSet(); da.Fill(ds); DataView dv = new DataView(); dv = ds.Tables[0].DefaultView; dv.Sort = "studName"; DataTabledt = dv.Table; GridView1.DataSource = dt; GridView1.DataBind(); } }
|
|
14) In which Event you can set the value of a Theme?
a. Page_Load
b. Page_Render
c. Page_PreRender
d. Page_PreInit
Answer
Explanation
|
ANSWER: Page_PreInit
Explanation: To apply a theme programmatically, you can use to set the page’s Theme property in the Page_PreInitmethod. Page_PreInitis the proper method in which you can specify the theme.
|
|
15) You need to initialize some variable only when the first user accesses the application. What should you do?
a. Add code to the Application_OnStart event handler in the Global.asax file.
b. Add code to the Application_BeginRequest event handler in the Global.asax
c. Add code to the Session_OnStart event handler in the Global.asax file
d. None of the above
Answer
Explanation
|
ANSWER: Add code to the Application_OnStart event handler in the Global.asax file.
Explanation: Application_Start event runs only ones when the application started. It is used to serve application - level and session - level events.
|
|
16) Which of the following template supports by Repeater control?
a. <ItemTemplate>
b. <AlternatingItemTemplate>
c. <SeperatorTemplate>
d. All of the above
Answer
Explanation
|
ANSWER: All of the above
Explanation: Repeater is a web server control. It is used to create custom lists out of data that is available on the page. Repeater control supports different type of template because it has not any built in layout.
Following are the template that a repeater control supports. • ItemTemplate • AlternatingItemTemplate • SeparatorTemplate • HeaderTemplate and FooterTemplate
|
|
17) Which of the following works on client side?
a. ViewState
b. HiddenField
c. ControlState
d. All of the above
Answer
Explanation
|
ANSWER: All of the above
Explanation: The following objects works on the client side in ASP.NET.
1. view state. It works within the page only. You cannot use view state value in next page. 2. control state: You can persist information about a control that is not part of the view state. If view state is disabled for a control or the page, the control state will still work. 3. hidden fields: It store data without displaying that control and data to the user’s browser. Hidden fields data is available within the page only (page - scoped data). 4. Cookies: Cookies are small piece of information that server creates on the browser. Cookies store a value in the user’s browser that the browser sends with every page request to the web server. 5. Query strings: In query strings values are stored at the end of the URL. These values are visible to the user through his or her browser’s address bar. Query strings are not secure.
|
|
18) Which of the following works on server side?
a. ViewState
b. HiddenField
c. Application and session
d. All of the above
Answer
Explanation
|
ANSWER: Application and session
Explanation: Application and session objects works on the server side and more secure than client side objects.
• Application State: This object stores the data that is accessible to all pages in a given Web application. • Session State: Session object store user - specific data between individual requests. This object is same as application object but it stores the data about particular user.
|
|
19) Application_Start event is available in which file?
a. Global.asax
b. Local.asax
c. Web.config
d. None of the above
Answer
Explanation
|
ANSWER: Global.asax
Explanation: Application_Start event is available in Global.asax file. Application_Start event runs only ones when the application started. It is used to serve application-level and session-level events. The following are some of the important events in the Global.asax file. • Application_Start • Session_Start • Application_BeginRequest • Application_EndRequest • Application_Error • Session_End • Application_End
|
|
20) You have to log the data into database if your session times out. Which event you will use?
a. Session_End
b. Application_End
c. Application_Start
d. Application_SessionTimeout
Answer
Explanation
|
ANSWER: Session_End
Explanation: The Session_End Event is fired whenever a single user Session ends or times out. By using timeout property of session state you can control the session expire time. A session expires when the time specified by the Timeout property passes without a request came from the user.
|
|
21) Which of the following is true when referencing master page from content page?
a. Content pages can reference private indexer in the master page.
b. Content pages can reference private Properties in the master page.
c. Contentpages can reference public Properties in the master page.
d. Content pages can reference private Methods in the master page.
Answer
Explanation
|
ANSWER: Contentpages can reference public Properties in the master page.
Explanation: You can access the Properties and Controls of Master Pages from content pages. You can set value inside the master page and then make it available to content pages as a property of the master page.
|
|
22) If you are using Webparts in your web page then which control is necessary?
a. WebpartController
b. WebPartmanager
c. WebpartZone
d. None of the above
Answer
Explanation
|
ANSWER: WebPartmanager
Explanation: WebPartmanager control is necessary for using webparts in ASP.NET. This control will manage different webpart in web page. When you run the application you will not see any WebPartmanager control because it is a non - visual control. It is most important control while using weparts. It provides the functionality for adding, deleting, and closing WebPart controls on a page.
|
|
23) What component do you need to enable for a user to add new web parts?
a. WebpartZone
b. CatalogZone
c. WebPartManager
d. WebManager
Answer
Explanation
|
ANSWER: CatalogZone
Explanation: CatalogZone control is required to add new web parts. This control is works like a container for other controls. CatalogPart control can be added on CatalogZone only.
|
|
24) Which of the following are required to enable users to change the title of web part?
a. CatalogZone
b. TitleZone
c. EditorZone, AppearanceEditorPart
d. WebPart
Answer
Explanation
|
ANSWER: EditorZone, AppearanceEditorPart
Explanation: EditorZone enables the user to edit appearance, layout, behavior, and other properties of the visible WebPart controls. So you can change the title of web part by using these controls.
|
|
25) What is the file extension of web service in ASP.NET?
a. .ascx
b. .asmx
c. .aspx
d. .docx
Answer
Explanation
|
ANSWER: .asmx
Explanation: .asmx is the file extension of web service in ASP.NET
|
|
26) If you want to access a web service method, which attribute it must have?
a. [WebMethod]
b. [PageMetod]
c. [Web.Service]
d. [WebSupport]
Answer
Explanation
|
ANSWER: [WebMethod]
Explanation: A web service is a web-based functionality that is used by other web application. WebMethod attribute is used with methods within an XML Web service. This attribute makes the method callable from remote Web clients.
Example: [WebMethod()]
public int Add(int a, int b) { return (a + b); }
|
|
27) Range Validator control in ASP.NET supports which type?
a. Integer
b. String
c. Currency
d. All of the above
Answer
Explanation
|
ANSWER: All of the above
Explanation: The RangeValidator control checks whether a user's input data is between a specified upper and lower value. This controls supports the following type. • String • Integer • Double • Date • Currency
|
|
28) If you are using user control in ASP.NET page which directory will be used?
a. Register
b. Assembly
c. Implements
d. Aspx
Answer
Explanation
|
ANSWER: Register
Explanation: @register directive will be used, when you drag a user control onto your page. This directive registers your user control on the page so that the control can be accessed by the page. @Register directive informs the compiler that a user control added to the page. In ASP.NET the extension of user control is .ascx.
|
|
29) A web application can contain _______ .
a. Only One Web.Config File
b. Only Two Web.Config File
c. more than one Web.config file
d. No file.
Answer
Explanation
|
ANSWER: more than one Web.config file
Explanation: A web application can contain more than one Web.config file. When you create a web application, visual studio provide a default Web.config file in the root for you. For using more than one Web.config file, first you have to add a folder than you can add new Web.config file in this sub folder. There can be one web.config file in every sub folder of the application.
|
|
30) What is the last event of web page life cycle?
a. Page_Load
b. Page_LoadComplete
c. Page_Finish
d. Page_Unload
Answer
Explanation
|
ANSWER: Page_Unload
Explanation: When an ASP.NET page runs, the page goes through a series of events. These step by step events are called as page life cycle. The first event is Page_PreInit and last event is Page_Unload. The following are the list of page life cycle event.
• PreInit • Init • InitComplete • PreLoad • Load • LoadComplete • PreRender • PreRenderComplete • SaveStateComplete • Render • Unload
|
|
31) ByDefault ASP.Net SessionID is stored in _________.
a. Application
b. Session
c. Cookies
d. ViewState
Answer
Explanation
|
ANSWER: Cookies
Explanation: ByDefault ASP.Net SessionID is stored in cookies. SessionID enables you to retrieve the unique session identifier of a particular user. By default, Session state depends on cookies. SessionID is stored in a cookie named ASP.NET_SessionId to identity a user. If a user disables cookies in the browser, then Session state doesn’t work. The ASP.NET_SessionId cookie is used to associate the correct data with the correct user.
|
|