ASP.NET with SQL Server MCQs

ASP.NET with SQL Server MCQs

ASP.NET with SQL Server MCQs will test your knowledge. Our Free ASP.NET with SQL Server multiple-choice questions and answers are in quiz format, so test your skill in an easy and fun way.

1:

Which of the following are false for ASP.NET events?

A.   Events are specialized forms of delegates

B.   Events are used to support the callback event notification model

C.   The signature of any event handler is fixed

D.   All of the above are true

2:

You create an ASP.NET application for an online insurance site PremiumInsurance. A page named PersonalDetails.aspx has the following Page directive:

<%@ Page Language="VB" CodeBehind="PersonalDetails.aspx.vb" AutoEventWireup="false" inherits="InsApp.PersonalDet"%> PersonalDetails.aspx had a TextBox control named MemberID in which the user can enter a Personal MemberID. The HTML code for this control is as follows: <asp:TextBox ID="MemberID" Columns="20" Runat="server"/> You need to implement a TextChanged event handler for MemberID. You want this event handler to retrieve information about a person by using an XML Web service that charges for each access. The page will then be redisplayed with additional information about the vehicle obtained from the XML Web service. You are implementing the TextChanged event handler. Which two courses of action should you take? (Each correct answer presents part of the solution. Choose two)

A.   In the Page directive for PersonalDetails.aspx, ensure that the AutoEventWireup attributes is set to "true".

B.   In the Page directive for PersonalDetails.aspx, ensure that the EnableViewState attribute is set to "true".

C.   In the MemberID HTML element, ensure that the AutoPostback attribute is set to "false". Include code for the client-side onserverchange event to submit the Web Form for processing by theserver

D.   In the MemberID HTML element, ensure that the AutoPostback attribute is set to "true". Include code in the TextChanged event handler to query the XML Web service

3:

You create an ASP.NET application for ABC Corporation. The project manager requires a standard appearance for all Web applications. Standards are expected to change periodically. You need to enforce these standards and reduce maintenance time. What would you do?

A.   Create a Microsoft Visual Studio .NET Enterprise template

B.   Create a sample HTML page

C.   Create a sample ASP.NET Web form

D.   Create a cascading style sheet

4:

Which of the following are not true in ASP.NET?

A.   A try block can have more than one catch blocks

B.   Every try block must have a catch block

C.   Every try block must have a finally block

D.   All exception classes are to be derived from System.Exception

5:

You are creating an ASP.NET application for AutoMart Internet Web site. A toolbar is required that will be displayed at the top of each page in the Web site. The toolbar will contain only static HTML code. The toolbar will be used in only AutoMart website. You plan to create the toolbar as a reusable component for your application. You need to create the toolbar in a minimum possible time. Which method will you adopt?

A.   Add a new component class to your ASP.NET project. Use HTML server controls to design the toolbar within the designer of the component class.

B.   Create a new Web Control Library project. Create the toolbar within a Web custom control.

C.   Add a new Web user control to your ASP.NET project. Create the toolbar within the Web user control.

D.   Add a new Web Form to your ASP.NET project. Use HTML server controls to design the toolbar within the Web Form and save the Web Form with an ascx extension

6:

You are creating an ASP.NET application that will run on your company's intranet. You want to control the browser window and respond immediately to non-post-back events. Which should you use?

A.   Server-side code

B.   Use the Browser object's VBScript or JavaScript properties to test if the browser can run scripts

C.   Use the Browser object's Cookies

D.   Client-side scripts

7:

You are developing an application to take orders over the Internet. When the user posts back the order form, you first check to see whether he is a registered customer of your company. If not, you must transfer control to the Register html page. Which method should you use to effect this transfer?

A.   Response.Redirect()

B.   Server.Transfer()

C.   Server.Execute()

D.   Page.ProcessRequest()

8:

Consider the following two statements relating to ASP.NET and choose the most appropriate option?

Statement 1: Value types are allocated on a stack

Statement 2: Reference types are allocated on a managed CLR Heap

A.   Statement 1 is true and statement 2 is false

B.   Statement 2 is true and statement 1 is false

C.   Both statements 1 and 2 are true

D.   Both statements 1 and 2 are false

9:

How can you pop-up a window to display text that identifies the author of the book?

A.   For each image, set the AlternateText property to specify the text you want to display, and set the ToolTip property to True.

B.   In the onmouseover event handler for each image, add code that calls the RaiseBubbleEvent() method of the System.Web.UI.WebControls.Image class.

C.   In the onmouseover event handler for each image, add code that calls the ToString() method of the System.Web.UI.WebControls.Image class.

D.   For each image, set the ToolTip property to specify the text you want to display.

10:

In ASP.NET, the control's value set during the postback can be accessed in?

A.   Page_Init

B.   Page_Load

C.   Both Page_Init and Page_Load

D.   Neither in Page_Load nor Page_Init

11:

Which of the following is not a service provided by Common Language Runtime (CLR)?

A.   Garbage collection

B.   Multiple platform support

C.   Code verification

D.   Code access security

12:

What does the following line of code do?

<%@ Register tagprefix="ril" Tagname="test" Src="rilTest.ascx" %>

A.   Register a new web site

B.   Register a new tag

C.   Register a new user control

D.   Register a new web page

13:

What will happen if the Server configuration file and the Application configuration file have different values for session state?

A.   The Server configuration will always override the Application configuration

B.   The Application configuration will always override the Server configuration

C.   The Server configuration will override the Application configuration if allowOverride is set to "false" in the settings in the Server configuration file

D.   The Application configuration will override the Server configuration if allowOverride is set to "false" in the settings in the Server configuration file

14:

What data types do the RangeValidator control support?

A.   Integer, String, and Date

B.   char, String, and Date

C.   Integer, String, and varchar

D.   Integer, bool, and Date

15:

Which of following is correct if you want to import a C# class called myClass that is implemented in the myClass.cs file into a .aspx page?

A.   <%@Page Import="myClass" Src="myClass.cs" %>

B.   <%@Page Inherits="myClass" Src="myClass.cs" %>

C.   <%@Page Include="myClass" Src="myClass.cs" %>

D.   <%@Page Insert="myClass" Src="myClass.cs" %>

16:

Which DLL is responsible for processing the page requests running on the server?

A.   Internet Server Application Programming Interface

B.   Internet Information Server Program

C.   Webserver interface

D.   IIS Application

17:

In which of the following namespaces is the Assembly class defined?

A.   System.Assembly

B.   System.Reflection

C.   System.Collections

D.   System.Object

18:

Which of the following are the valid methods of the SqlTransaction class?

A.   Commit

B.   Terminate

C.   Save

D.   Close

E.   Rollback

19:

In ASP.NET, which of the following is not an event of the Page class?

A.   Init

B.   Load

C.   Error

D.   Abort

20:

Which of the following is not a valid directive in ASP.NET?

A.   @Page

B.   @Implements

C.   @Insert

D.   @Register

E.   @Reference

21:

Which of the following is the way to handle Unmanaged Code Exceptions in ASP.NET?

A.   Server.GetLastError()

B.   Exception ex

C.   Exception ex

D.   None of above

22:

How can you view the results of Trace.Write() statements?

A.   By enabling page tracing

B.   By enabling application tracing

C.   By enabling server tracing

D.   By looking up the system.log file

23:

Consider the following two statements and choose the most appropriate option:

1. For configuration, ASP.NET uses IIS Metabase

2. For configuration, ASP.NET uses an XML based configuration system

A.   1 only

B.   2 only

C.   Both 1 and 2

D.   Neither 1 nor 2

24:

When you make some changes to the configuration file, do you need to stop and start IIS to apply the new settings?

A.   Yes

B.   No

25:

Which of the following directives can be used to include libraries in an ASP.NET page?

A.   Include

B.   Import

C.   Insert

D.   Both a and b

26:

In ASP.NET, the exception handling should be used?

A.   To signal the occurrence of unusual or unanticipated program events

B.   To redirect the program's normal flow of control

C.   In cases of potential logic or user input errors

D.   In case of overflow of an array boundary

27:

Which of the following scenarios are applicable to Window Workflow Foundation?

A.   Document-centric workflows

B.   Human workflows

C.   User-interface page flows

D.   Builtin support for communications across multiple applications and/or platforms

28:

The names of those departments where there are more than 100 employees have to be displayed. Given two relations, employees and departments, what query should be used?

Employee

---------

Empno

Employeename

Salary

Deptno

Department

---------

Deptno

Departname

A.   Select departname from department where deptno in (select deptnofrom employee group by deptno having count(*) > 100);

B.   Select departname from department where deptno in (select count(*)from employee group by deptno where count(*) > 100);

C.   Select departname from department where count(deptno) > 100;

D.   Select departname from department where deptno in (select count(*)from employee where count(*) > 100);

29:

Which of the following is not a valid SQL OPERATOR?

A.   Between..and..

B.   Like

C.   In

D.   Is null

E.   Having

F.   Not in

G.   All of the above are valid

30:

Consider the query:

SELECT name    

FROM Student    

WHERE name LIKE '_a%';

Which names will be displayed?

A.   Names starting with "a"

B.   Names containing "a" as the second letter

C.   Names starting with "a" or "A"

D.   Names containing "a" as any letter except the first

31:

Examine the code given below:

SELECT employee_id FROM employees WHERE commission_pct=.5 OR salary > 23000

Which of the following statements is correct with regard to this code?

A.   It returns employees whose salary is 50% more than $23,000

B.   It returns employees who have 50% commission rate or salary greater than $23,000

C.   It returns employees whose salary is 50% less than $23,000

D.   None of the above

32:

Which of the following are aggregate functions in SQL?

A.   Avg

B.   Select

C.   Order By

D.   Sum

E.   Union

F.   Group by

G.   Having

33:

What is the correct SQL syntax for selecting all the columns where the "LastName" is alphabetically between (and including) "Hansen" and "Pettersen"?

A.   SELECT * FROM Persons WHERE LastName > 'Hansen', LastName < 'Pettersen'

B.   SELECT LastName > 'Hansen' AND LastName < 'Pettersen' FROM Persons

C.   SELECT * FROM customers WHERE LastName > 'Hansen' AND LastName > 'Pettersen'

D.   SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'

34:

It is time for the annual sales awards at your company. The awards include certificates awarded for the five sales of the highest sale amounts. You need to produce a list of the five highest revenue transactions from the Orders table in the Sales database. The Orders table is defined as follows:

CREATE TABLE Orders (        

OrderID Int IDENTITY NOT NULL,       

 SalesPersonID Int NOT NULL,       

 RegionID Int NOT NULL,        

OrderDate Datetime NOT NULL,        

 

OrderAmount Int NOT NULL )

Which statement will produce the report correctly?

A.   SELECT TOP 5 OrderAmount, SalesPersonID FROM orders

B.   SELECT TOP 5 OrderAmount, SalesPersonID FROM orders ORDER BY OrderAmount DESC

C.   SELECT TOP 5 WITH TIES OrderAmount, SalesPersonID From Orders

D.   SELECT TOP 5 WITH TIES OrderAmount, SalesPersonID From Orders ORDER BY OrderAmount

35:

Which of the following has the highest order of precedence in SQL Server?

A.   Functions and Parenthesis

B.   Multiplication, Division and Exponents

C.   Addition and Subtraction

D.   Logical Operations

36:

Which of the following constraints can be used to enforce the uniqueness of rows in a table?

A.   DEFAULT and NOT NULL constraints

B.   FOREIGN KEY constraints

C.   PRIMARY KEY and UNIQUE constraints

D.   IDENTITY columns

E.   CHECK constraints

37:

In which sequence are queries and sub-queries executed by the SQL Engine?

A.   primary query -> sub query -> sub sub query and so on

B.   sub sub query -> sub query -> prime query

C.   the whole query is interpreted at one time

D.   there is no fixed sequence of interpretation, the query parser takes a decision on the fly

38:

Which query will display data from the Pers table relating to Analysts, clerks and Salesmen who joined between 1/1/2005 and 1/2/2005?

A.   select * from Pers where joining_date from '1/1/2005' to '1/2/2005', job= 'Analyst' or 'clerk' or 'salesman'

B.   select * from Pers where joining_date between '1/1/2005' to '1/2/2005', job= 'Analyst' or job= 'clerk' or job= 'salesman'

C.   select * from Pers where joining_date between '1/1/2005' and '1/2/2005' and (job= 'Analyst' or 'clerk' or 'salesman')

D.   None of the above

39:

Which of the following datatypes is not supported by SQL-Server?

A.   Character

B.   Binary

C.   Logical

D.   Date

E.   Numeric

F.   All are supported

40:

What is the order of precedence among the following operators?

1. IN

2. NOT

3. AND

4. OR

A.   1,2,3,4

B.   2,3,4,1

C.   1,2,4,3

D.   1,4,3,2

E.   4,3,2,1

F.   4,1,2,3

G.   4,2,1,3

H.   3,2,1,4

41:

The simplest query must include at least________ and _________?

A.   A select clause

B.   A where clause

C.   A from clause

D.   A group by clause

E.   A having clause

F.   An order by clause

42:

You want to display the titles of books that meet the following criteria:

1. Purchased before November 11, 2002

2. Price is less than $500 or greater than $900

You want to sort the result by the date of purchase, starting with the most recently bought book.

Which of the following statements should you use?

A.   SELECT book_title FROM books WHERE price between 500 and 900 AND purchase_date < '11/11/2002' ORDER BY purchase_date;

B.   SELECT book_title FROM books WHERE price IN (500, 900) AND purchase_date< '11/11/2002' ORDER BY purchase date ASC;

C.   SELECT book_title FROM books WHERE price < 500 OR>900 AND purchase_date DESC;

D.   SELECT Book_title FROM books WHERE (price < 500 OR price > 900) AND purchase_date < '11/11/2002' ORDER BY purchase date DESC

43:

Is the FROM clause necessary in every SELECT statement?

A.   Yes

B.   No

44:

Is it possible to insert several rows into a table with a single INSERT statement?

A.   No

B.   Yes

45:

Which line of code should you use to copy the edited rows from dataset productInfo into another dataset productChanges?

A.   productChanges = productInfo.GetChanges(DataRowState.Detached)

B.   productChanges = productInfo.GetChanges()

C.   productChanges.Merge(productInfo, true)

D.   productChanges.Merge(productInfo, false)

46:

Consider the following queries:

1. select * from employee where department LIKE "[^F-M]%";

2. Select * from employee where department = "[^F-M]%";

Select the correct option:

A.   Query 2 will return an error

B.   Both the queries will return the same set of records

C.   Query 2 is perfectly correct

D.   Query 2 would return one record less than Query 1

47:

What is wrong with the following query?

select * from Orders where OrderID = (select OrderID from OrderItems where ItemQty > 50)

A.   In the sub query, '*' should be used instead of 'OrderID'

B.   The sub query can return more than one row, so, '=' should be replaced with 'in'

C.   The sub query should not be in parenthesis

D.   None of the above

48:

A production house needs a report about the sale where total sale of the day is more than $20,000. Which query should be used?

A.   select * from orders where sum(amount) > 20000

B.   select * from orders where sum(amount) > 20000 order by OrderDate

C.   select * from orders group by OrderDate having sum(amount)>20000

D.   select * from orders group by OrderDate where sum(amount) > 20000

49:

Examine the description of the STUDENTS table:

STD_ID                INT

COURSE_ID        VARCHAR (10)

START_DATE        DATETIME

END_DATE        DATETIME

 

The aggregate functions valid on the START_DATE column are:

A.   SUM(start_date)

B.   AVG(start_date)

C.   COUNT(start_date)

D.   AVG(start_date, end_date)

E.   MIN(start_date)

50:

Which of the following objects is required by the Dataset to retrieve data from a database and to save updated data back to the database?

A.   DataAdapter

B.   DataReader

C.   Command

D.   Connection