Online Test ASP.NET with SQL Server

Online Test ASP.NET with SQL Server

  1. Events are specialized forms of delegates
  2. Events are used to support the callback event notification model
  3. The signature of any event handler is fixed
  4. All of the above are true
Answer: Answer is d

<%@ 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)
  1. In the Page directive for PersonalDetails.aspx, ensure that the AutoEventWireup attributes is set to "true".
  2. In the Page directive for PersonalDetails.aspx, ensure that the EnableViewState attribute is set to "true".
  3. 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
  4. 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
Answer: Answer is a, d

  1. Create a Microsoft Visual Studio .NET Enterprise template
  2. Create a sample HTML page
  3. Create a sample ASP.NET Web form
  4. Create a cascading style sheet
Answer: Answer is d
Further Reading:
Useful resources, CSS Overview

  1. A try block can have more than one catch blocks
  2. Every try block must have a catch block
  3. Every try block must have a finally block
  4. All exception classes are to be derived from System.Exception
Answer: Answer is b, c
Further Reading:
A try block must have either a catch block or finally block. Useful resources, try-catch-finallytry-finallytry-catchException Class

XYZ is creating an e-commerce site for PremiumBoutique. The site is distributed across multiple servers in a Web farm. Users will be able to navigate through the pages of the site and select products for purchase. XYZ wants to use a DataSet object to save their selections. Users will be able to view their selections at any time by clicking a Shopping Cart link. XYZ wants to ensure that each user's shopping cart DataSet object is saved between requests when the user is making purchases on the site.
How can this requirement be implement?
  1. Create a StateBag object. Use the StateBag object to store the DataSet object in the page's ViewState property
  2. Use the HttpSessionState object returned by the Session property of the page to store the DataSet object. Use the Web.config file to configure an out-of-process session route
  3. Use the Cache object returned by the page's Cache property to store a DataSet object for each user. Use an HttpCachePolicy object to set a timeout period for the cached data
  4. Use the Session_Start event to create an Application variable of type DataSet for each session. Store the DataSet object in the Application variable
Answer: Answer is b

  1. 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.
  2. Create a new Web Control Library project. Create the toolbar within a Web custom control.
  3. Add a new Web user control to your ASP.NET project. Create the toolbar within the Web user control.
  4. 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
Answer: Answer is c
Further Reading:
Useful resources, ASP.NET User Controls

  1. Server-side code
  2. Use the Browser object's VBScript or JavaScript properties to test if the browser can run scripts
  3. Use the Browser object's Cookies
  4. Client-side scripts
Answer: Answer is d
Further Reading:
As we do not need to send or receive anything from server, client side script is the best approach to interact with user’s activity.Useful resources, Client-Side Script

  1. Response.Redirect()
  2. Server.Transfer()
  3. Server.Execute()
  4. Page.ProcessRequest()
Answer: Answer is a

Your company, StoreIt Inc has stored the text of several journals in a Microsoft SQL Server 7.0 database. Each sentence is stored in a separate record so that  the text can be retrieved with the finest granularity. Several of these works are many thousands of printed pages in length. You are building a Web application that will allow registered users to retrieve data from these volumes. When a user of your Web application requests large amounts of text, your application must return it in the most efficient manner possible. How should you build the large String object that is required to provide the most efficient response to the user?
  1. Use a RichTextBox object to hold the data as it is being concatenated.
  2. Use the Append method of the String class.
  3. Use the String class and the & operator.
  4. Use the StringBuilder class.
Answer: Answer is d
Further Reading:
Useful resources, StringBuilder class

Statement 1: Value types are allocated on a stack
Statement 2: Reference types are allocated on a managed CLR Heap
  1. Statement 1 is true and statement 2 is false
  2. Statement 2 is true and statement 1 is false
  3. Both statements 1 and 2 are true
  4. Both statements 1 and 2 are false
Answer: Answer is c
Further Reading:
Value types are either stack-allocated or allocated inline in a structure. Reference types are heap-allocated. Both reference and value types are derived from the ultimate base class Object. Useful resources,ValueType


  1. For each image, set the AlternateText property to specify the text you want to display, and set the ToolTip property to True.
  2. In the onmouseover event handler for each image, add code that calls the RaiseBubbleEvent() method of the System.Web.UI.WebControls.Image class.
  3. In the onmouseover event handler for each image, add code that calls the ToString() method of the System.Web.UI.WebControls.Image class.
  4. For each image, set the ToolTip property to specify the text you want to display.
Answer: Answer is d
Further Reading:
Useful resources, ToolTip

  1. Page_Init
  2. Page_Load
  3. Both Page_Init and Page_Load
  4. Neither in Page_Load nor Page_Init
Answer: Answer is b
Further Reading:
The control’s value set during the postback can be accessed in Page_Load.

You create an ASP.NET page named Customer.aspx. Customer.aspx contains a Web user control that displays a drop-down list box of Cities. The Web user control is named CityList, and it is defined in a file named CityList.ascx. The name of the DropDownList control in City.ascx is CuCity. You try to add code to the Page.Load event handler for Customer.aspx, but you discover that you cannot access CuCity from code in Customer.aspx. You want to ensure that code within Customer.aspx can access properties of CuCity.
What should you do?
  1. In the code-behind file for CityList.ascx, add the following line of code:Protected CuCity As DropDownList
  2. In the code-behind file for Customer.aspx, add the following line of code:Public CuCity As DropDownList
  3. In the code-behind file for Customer.aspx, add the following line of code:Protected CuCity As DropDownList
  4. In the code-behind file for CityList.ascx, add the following line of code:Public CuCity As DropDownList
Answer: Answer is d
Further Reading:
We need to declare CuCity as public to access it.

  1. Garbage collection
  2. Multiple platform support
  3. Code verification
  4. Code access security
Answer: Answer is b
Further Reading:

You are creating an ASP.NET application that will record each customer's entry. It is possible that thousands of entries could be posted at any given time. Your application will be hosted on twenty Web servers. As customers enter information into your application, maintaining state information will be important. This information should be stored securely and should be capable of being restored in the event that a Web server is restarted. Customers will enter data into three separate pages in your application.
Which of the following methods of storing state information would best suit the situation?
  1. View State
  2. Hidden fields
  3. State Server
  4. Application state
  5. SQL Server
Answer: Answer is e

<%@ Register tagprefix="ril" Tagname="test" Src="rilTest.ascx" %>
  1. Register a new web site
  2. Register a new tag
  3. Register a new user control
  4. Register a new web page
Answer: Answer is c
Further Reading:

You are debugging an ASP.NET application for Premium Corp.. Users will use the application to produce reports. Your application contains several Debug.WriteLine statements. Which window in Visual Studio .NET should you use to inspect output from the Debug.WriteLine statements?
  1. Command
  2. Locals
  3. Output
  4. Breakpoints
Answer: Answer is c
Further Reading:
Useful resources, Debug.WriteLine Method

  1. The Server configuration will always override the Application configuration
  2. The Application configuration will always override the Server configuration
  3. The Server configuration will override the Application configuration if allowOverride is set to "false" in the settings in the Server configuration file
  4. The Application configuration will override the Server configuration if allowOverride is set to "false" in the settings in the Server configuration file
Answer: Answer is b
Further Reading:
Settings in child directories can optionally override or modify settings that are specified in parent directories. Useful resources, ASP.NET ConfigurationASP.NET Configuration Hierarchy

(a)MSIL code is platform independent
(b)CLR is platform dependent
  1. Only (a) is true, (b) is false
  2. Only (b) is true, (a) is false
  3. Both (a) and (b) are true
  4. Both (a) and (b) are false
Answer: Answer is c

You are creating an ASP.NET page for your company's Web site. Customers will use the ASP.NET page to enter payment information. You add a DropDownList control named oPaymentTypeList that enables customers to select a type of credit card and bank accounts. You need to ensure that customers select a credit card type. You want a default value of Select to be displayed in the oPaymentTypeList control. You want the page validation to fail if a customer does not select a payment type from the list. What should you do?
  1. Add a RequiredFieldValidator control and set its ControlToValidate property to oPaymentTypeList. Set the InitialValue property of the RequiredFieldValidator control to Select.
  2. Add a RequiredFieldValidator control and set its ControlToValidate property to oPaymentTypeList. Set the DataTextField property of the oPaymentTypeList control to Select.
  3. Add a CustomValidator control and set its ControlToValidate property to oPaymentTypeList. Set the DataTextField property of the oPaymentTypeList control to Select.
  4. Add a RegularExpressionValidator control and set its ControlToValidate property to oPaymentTypeList. Set the ValidateExpression property of the RegularExpressionValidator control to Select.
Answer: Answer is a
Further Reading:
Useful resources, RequiredFieldValidator


You are creating an ASP.net application to enter timesheet data intuitively. Users will enter data using a DataGrid. You have added a button column to your DataGrid. The button column uses a custom button to allow users to initiate some calculations on the data in the grid. Which event does the DataGrid control raise when the custom button is clicked?
  1. EditCommand
  2. OnClick
  3. ButtonClicked
  4. ItemCommand
Answer: Answer is d
Further Reading:
Useful resources, DataGrid.ItemCommand

  1. Integer, String, and Date
  2. char, String, and Date
  3. Integer, String, and varchar
  4. Integer, bool, and Date
Answer: Answer is a
Further Reading:

  1. <%@Page Import="myClass" Src="myClass.cs" %>
  2. <%@Page Inherits="myClass" Src="myClass.cs" %>
  3. <%@Page Include="myClass" Src="myClass.cs" %>
  4. <%@Page Insert="myClass" Src="myClass.cs" %>
Answer: Answer is b

  1. Internet Server Application Programming Interface
  2. Internet Information Server Program
  3. Webserver interface
  4. IIS Application
Answer: Answer is a
Further Reading:
Useful resources, IIS Request Processing

The code is displayed below: <%@ Register TagPrefix=" CertKing Tag" Namespace="ReportNS" Assembly=" CertKing Report" %> You want to set the PageNumber property of the control to 77. Which of the following lines of code should you include in your Web Form?
  1. < CertKing Tag:ReportNS PageNumber="77" runat="server" />
  2. <myReport PageNumber="77" src="rptctrl" runat="server" />
  3. < CertKing Tag:myReport PageNumber="77" runat="server" />
  4. <% Control TagName="myReport" src="rptctrl" runat="server" %>
Answer: Answer is a

  1. System.Assembly
  2. System.Reflection
  3. System.Collections
  4. System.Object
Answer: Answer is b

  1. Commit
  2. Terminate
  3. Save
  4. Close
  5. Rollback
Answer: Answer is a, c, e
Further Reading:
Useful resources, SqlTransaction

<%@ Register Tagprefix="WoodySideBankControls" Namespace="WoodySideBankNameSpace" Assembly="MyAssembly" %> The assembly named MyAssembly contains a custom server control named CSC1. Which of the following code samples will properly render CSC1 on the Web page?
  1. <WoodySideBankControls:CSC1 id="Control1" runat="server" />
  2. <WoodySideBankNameSpace:CSC1 id="Control1" runat="server" />
  3. <WoodySideBankControls:Control1 id="CSC1" runat="server" />
  4. <WoodySideBankNameSpace:Control1 id="CSC1" runat="server" />
Answer: Answer is a

  1. Init
  2. Load
  3. Error
  4. Abort
Answer: Answer is d
Further Reading:
Useful resources, Page class

You are a web developer for an international literary website. Your application has a lot of text content that requires translation and few executable components.Which approach would you use?
  1. Detect and redirect
  2. Use run-time adjustment
  3. Use satellite assemblies
  4. Allow the client browser to decide
Answer: Answer is a

Sam is developing an application that enables the users to perform read and write operations on text files. He uses structured exception handling to handle the errors. He writes the code for closing all the files that were opened in the Finally block. Which of the following is true regarding the Finally block?
  1. Finally block will be executed only if an error occurs
  2. Finally block is executed after Catch block when no error occurs
  3. Finally block is executed after Try block regardless of whether an error occurs
  4. Finally block is executed only when no error occurs
Answer: Answer is c
Further Reading:

  1. @Page
  2. @Implements
  3. @Insert
  4. @Register
  5. @Reference
Answer: Answer is c

  1. Server.GetLastError()
  2. Exception ex
  3. Raise Error
  4. None of above
Answer: Answer i
Further Reading:

  1. By enabling page tracing
  2. By enabling application tracing
  3. By enabling server tracing
  4. By looking up the system.log file
Answer: Answer is a, b
Further Reading:
The Trace.Write() statements do not appear within the resulting output. To view the results of theTrace.Write() statements, we need to enable tracing for the page or for the application. Useful resources, tracing

1. For configuration, ASP.NET uses IIS Metabase
2. For configuration, ASP.NET uses an XML based configuration system
  1. 1 only
  2. 2 only
  3. Both 1 and 2
  4. Neither 1 nor 2
Answer: Answer is c
Further Reading:
Useful resources, ASP.NET Configuration Overview

  1. Yes
  2. No
Answer: Answer is b

<system.web>

<authorization>

<deny users="RIL"/>

<allow users="RIL"/>

</authorization>

</system.web>
  1. The user RIL is first denied and then allowed access
  2. The user RIL is denied access because the <deny> element takes precedence over the <allow> element
  3. An error is generated because deny and allow cannot both be assigned to the same user
  4. Can't say. It depends on the Windows OS version
Answer: Answer is b
Further Reading:
At run time, the authorization module iterates through the allow and deny elements, starting at the most local configuration file, until the authorization module finds the first access rule that fits a particular user account. Then, the authorization module grants or denies access to a URL resource depending on whether the first access rule found is an allow or a deny rule. Useful resources, deny allow Element for authorization

You are creating an ASP.NET application. The application will be deployed on intranet. Application uses Microsoft Windows authentication. More than 100 users will use the ASP.NET application simultaneously. What setting should be done by the project manager regarding user authentication?
  1. Add the following element to the authentication section of the Web.config file: <allow users="?"/>
  2. Use the Configuration Manager for your project to designate the user's security context.
  3. Write code in the Application_AuthenticateRequest event handler to configure the application to run in the user's security context.
  4. Add the following element to the system.web section of the Web.config file: <identity impersonate="true"/>
Answer: Answer is a
Further Reading:

  1. Include
  2. Import
  3. Insert
  4. Both a and b
Answer: Answer is b

  1. To signal the occurrence of unusual or unanticipated program events
  2. To redirect the program's normal flow of control
  3. In cases of potential logic or user input errors
  4. In case of overflow of an array boundary
Answer: Answer is c


  1. Document-centric workflows
  2. Human workflows
  3. User-interface page flows
  4. Builtin support for communications across multiple applications and/or platforms
Answer: Answer is a, b, c
Further Reading:
Useful resources, Windows Workflow Foundation

  1. Create table Pers
  2. (EmpNo Int not null,
  3. EName Char not null, 
  4. Join_dt Datetime not null,
  5. Pay Int)
Which line contains an error?
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. None
Answer: Answer is f
Further Reading:
Useful resources, creating a table

Employee
---------
Empno
Employeename
Salary
Deptno
Department
---------
Deptno
Departname
  1. Select departname from department where deptno in (select deptnofrom employee group by deptno having count(*) > 100);
  2. Select departname from department where deptno in (select count(*)from employee group by deptno where count(*) > 100);
  3. Select departname from department where count(deptno) > 100;
  4. Select departname from department where deptno in (select count(*)from employee where count(*) > 100);
Answer: Answer is a
Further Reading:
Other option (except a) will not execute due to error in the statement. Useful resources, SQL basic queriesquery fundamentalHAVING ClauseCOUNTSQL IN

  1. Between..and..
  2. Like
  3. In
  4. Is null
  5. Having
  6. Not in
  7. All of the above are valid
Answer: Answer is g
Further Reading:
Useful resources, SQL OperatorsOperator Precedence

SELECT name     
FROM Student     
WHERE name LIKE '_a%';
Which names will be displayed?
  1. Names starting with "a"
  2. Names containing "a" as the second letter
  3. Names starting with "a" or "A"
  4. Names containing "a" as any letter except the first
Answer: Answer is b
Further Reading:
Useful resources, LIKE operator

SELECT employee_id FROM employees WHERE commission_pct=.5 OR salary > 23000
Which of the following statements is correct with regard to this code?
  1. It returns employees whose salary is 50% more than $23,000
  2. It returns employees who have 50% commission rate or salary greater than $23,000
  3. It returns employees whose salary is 50% less than $23,000
  4. None of the above
Answer: Answer is b
Further Reading:
Useful resources, SQL basic queriesquery fundamental

  1. Avg
  2. Select
  3. Order By
  4. Sum
  5. Union
  6. Group by
  7. Having
Answer: Answer is a, d
Further Reading:
Useful resources, Aggregate Functions

  1. Select
  2. order by
  3. where
  4. having
  5. group by
  1. 1,2,3,4,5
  2. 1,3,5,4,2
  3. 1,3,5,2,4
  4. 1,3,2,5,4
  5. 1,3,2,4,5
  6. 1,5,2,3,4
  7. 1,4,2,3,5
  8. 1,4,3,2,5
Answer: Answer is b
Further Reading:
The order should be like this select>where>group by>having>order by. Useful resources, SQL basic queriesquery fundamentalHAVING Clause

SELECT e.employee_id, (.15* e.salary) + (.5 * e.commission_pct) + (s.sales_amount * (.35 * e.bonus)) AS CALC_VALUE FROM employees e, sales WHERE e.employee_id = s.emp_id;
What will happen if all the parentheses are removed from the calculation?
  1. The value displayed in the CALC_VALUE column will be lower
  2. The value displayed in the CALC_VALUE column will be higher
  3. There will be no difference in the value displayed in the CALC_VALUE column
  4. An error will be reported
Answer: Answer is d
Further Reading:
But if we use “SELECT e.employee_id, (.15* e.salary) + (.5 * e.commission_pct) + (s.sales_amount * (.35 * e.bonus)) AS CALC_VALUE FROM employees e, sales s WHERE e.employee_id = s.emp_id” then result will be displayed. Notice that s is missing after sales in the original query. Useful resources, SQL basic queriesquery fundamentalUsing Table Aliases

  1. SELECT * FROM Persons WHERE LastName > 'Hansen', LastName < 'Pettersen'
  2. SELECT LastName > 'Hansen' AND LastName < 'Pettersen' FROM Persons
  3. SELECT * FROM customers WHERE LastName > 'Hansen' AND LastName > 'Pettersen'
  4. SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'
Answer: Answer is d
Further Reading:
Useful resources, BETWEEN


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?
  1. SELECT TOP 5 OrderAmount, SalesPersonID FROM orders
  2. SELECT TOP 5 OrderAmount, SalesPersonID FROM orders ORDER BY OrderAmount DESC
  3. SELECT TOP 5 WITH TIES OrderAmount, SalesPersonID From Orders
  4. SELECT TOP 5 WITH TIES OrderAmount, SalesPersonID From Orders ORDER BY OrderAmount
Answer: Answer is b
Further Reading:
The company need the highest sate amount. So we need to order amount in DESC order. Useful resources, TOPWITH TIES

  1. Functions and Parenthesis
  2. Multiplication, Division and Exponents
  3. Addition and Subtraction
  4. Logical Operations
Answer: Answer is a
Further Reading:

  1. DEFAULT and NOT NULL constraints
  2. FOREIGN KEY constraints
  3. PRIMARY KEY and UNIQUE constraints
  4. IDENTITY columns
  5. CHECK constraints
Answer: Answer is c
Further Reading:
Useful resources, Constraints

  1. primary query -> sub query -> sub sub query and so on
  2. sub sub query -> sub query -> prime query
  3. the whole query is interpreted at one time
  4. there is no fixed sequence of interpretation, the query parser takes a decision on the fly
Answer: Answer is b
Further Reading:
Primary query results depend on the sub query results, so sub query my execute first then primary query will execute.   Useful resources, Subquery Fundamentals

Each student can enroll into more than one class. Each class can accommodate more than one student.
  1. 1 to N
  2. 1 to 1
  3. M to N to 1
  4. M to N
  5. N to 1
Answer: Answer is d
Further Reading:

  1. select * from Pers where joining_date from '1/1/2005' to '1/2/2005', job= 'Analyst' or 'clerk' or 'salesman'
  2. select * from Pers where joining_date between '1/1/2005' to '1/2/2005', job= 'Analyst' or job= 'clerk' or job= 'salesman'
  3. select * from Pers where joining_date between '1/1/2005' and '1/2/2005' and (job= 'Analyst' or 'clerk' or 'salesman')
  4. None of the above
Answer: Answer is d

  1. Character
  2. Binary
  3. Logical
  4. Date
  5. Numeric
  6. All are supported
Answer: Answer is c
Further Reading:
Useful resources, Data Types

  1. IN
  2. NOT
  3. AND
  4. OR
  1. 1,2,3,4
  2. 2,3,4,1
  3. 1,2,4,3
  4. 1,4,3,2
  5. 4,3,2,1
  6. 4,1,2,3
  7. 4,2,1,3
  8. 3,2,1,4
Answer: Answer is b
Further Reading:
Useful resources, Operator Precedence

  1. A select clause
  2. A where clause
  3. A from clause
  4. A group by clause
  5. A having clause
  6. An order by clause
Answer: Answer is a, c
Further Reading:
Useful resources, SQL Queries

  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?
  1. SELECT book_title FROM books WHERE price between 500 and 900 AND purchase_date < '11/11/2002' ORDER BY purchase_date;
  2. SELECT book_title FROM books WHERE price IN (500, 900) AND purchase_date< '11/11/2002' ORDER BY purchase date ASC;
  3. SELECT book_title FROM books WHERE price < 500 OR>900 AND purchase_date DESC;
  4. SELECT Book_title FROM books WHERE (price < 500 OR price > 900) AND purchase_date < '11/11/2002' ORDER BY purchase date DESC
Answer: Answer is d
Further Reading:
Useful resources, WHERE Clause



  1. Yes
  2. No
Answer: Answer is b
Further Reading:
In the SELECT statement, the FROM clause is required except when the select list contains only constants, variables, and arithmetic expressions (no column names). Useful resources, FROM

  1. No
  2. Yes
Answer: Answer is b

  1. productChanges = productInfo.GetChanges(DataRowState.Detached)
  2. productChanges = productInfo.GetChanges()
  3. productChanges.Merge(productInfo, true)
  4. productChanges.Merge(productInfo, false)
Answer: Answer is b
Further Reading:
Useful resources, DataSet.GetChanges Method

You are creating an ASP.NET application that will record each customer's entry. It is possible that thousands of entries could be posted at any given time. Your application will be hosted on twenty Web servers. As customers enter information into your application, maintaining state information will be important. This information should be stored securely and should be capable of being restored in the event that a Web server is restarted. Customers will enter data into three separate pages in your application.
  1. View State
  2. Hidden fields
  3. State Server
  4. Application state
  5. SQL Server
Answer: Answer is e
Further Reading:
Only the SQL Server data will remain save after restarting the server.

  1. select * from employee where department LIKE "[^F-M]%";
  2. Select * from employee where department = "[^F-M]%";
Select the correct option:
  1. Query 2 will return an error
  2. Both the queries will return the same set of records
  3. Query 2 is perfectly correct
  4. Query 2 would return one record less than Query 1
Answer: Answer is c

select * from Orders where OrderID = (select OrderID from OrderItems where ItemQty > 50)
  1. In the sub query, '*' should be used instead of 'OrderID'
  2. The sub query can return more than one row, so, '=' should be replaced with 'in'
  3. The sub query should not be in parenthesis
  4. None of the above
Answer: Answer is b

  1. select * from orders where sum(amount) > 20000
  2. select * from orders where sum(amount) > 20000 order by OrderDate
  3. select * from orders group by OrderDate having sum(amount)>20000
  4. select * from orders group by OrderDate where sum(amount) > 20000
Answer: Answer is c
Further Reading:
Useful resources, HAVING clause

STD_ID                INT
COURSE_ID        VARCHAR (10) 
START_DATE        DATETIME
END_DATE        DATETIME

The aggregate functions valid on the START_DATE column are:
  1. SUM(start_date)
  2. AVG(start_date)
  3. COUNT(start_date)
  4. AVG(start_date, end_date)
  5. MIN(start_date)
Answer: Answer is c, e
Further Reading:
Useful resources, Use Aggregate Functions

  1. DataAdapter
  2. DataReader
  3. Command
  4. Connection
Answer: Answer is a

Marketing, Designing, production, Packing
What will be the result of the following query?
select * from table where department < 'marketing';
  1. The query will return "Designing, Packing"
  2. The query will return "Designing, production, Packing"
  3. The query will return "packing"
  4. Strings cannot be compared using < operator
  5. The query will return "Designing"
Answer: Answer is e



  1. Use UNIQUE constraints
  2. Use PRIMARY KEY constraints
  3. Use DEFAULT and NOT NULL constraints
  4. Use FOREIGN KEY constraints
  5. Use SET constraints
Answer: Answer is c

  1. Set conn = New connection ; With conn ; .Provider = "SqlOleDB" ; ConnectionString ="User ID=sa;"&& "Data Source= Neptune;"&& "Initial Catalog=ClassList"
  2. Set conn = New connection ; With conn ; .Provider = "Neptune" ; ConnectionString ="User ID=sa;"&& "Data Source= Neptune;"&& "Initial Catalog=ClassList"
  3. Set conn = New connection ; With conn ; .Provider = "SqlOleDB" ; ConnectionString ="User ID=sa;"&& "Data Source= Neptune;"
Answer: Answer is a

  1. Select * from students where marks > avg(marks);
  2. Select * from students order by marks where subject = 'SQL';
  3. Select * from students having subject ='SQL';
  4. Select name from students group by subject, name;
  5. Select group(*) from students;
  6. Select name,avg(marks) from students;
  7. g. None of the above
Answer: Answer is d

  1. MyAdapter.Fill(MyDataSet,"Customer")
  2. MyAdapter.Fill("MyDataSet",Customer).
  3. MyAdapter.Fill(MyDataSet)
  4. MyAdapter.Fill("MyDataSet")
Answer: Answer is a
Further Reading:

  1. Commit
  2. Terminate
  3. Save
  4. Close
  5. Rollback
Answer: Answer is a, c, e
Further Reading:
Useful resources, SqlTransaction Class

select (2/2/4) from tab1; where tab1 is a table with one row.
This would give a result of:
  1. 4
  2. 2
  3. 1
  4. 5
  5. 25
  6. 0
  7. 8
  8. 24
Answer: Answer is f

  1. 0
  2. NULL
  3. It will generate an error message
  4. Can't be determined
Answer: Answer is b

select (age + 3 * 4 / 2 - 8) from emp
  1. +
  2. -
  3. /
  4. *
Answer: Answer is d
Further Reading:
Useful resources, Operator Precedence

SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY salary DESC
SELECT last_name, salary, hire_date FROM EMPLOYEES ORDER BY 2 DESC
What is true about them?
  1. The two statements produce identical results
  2. The second statement returns an error
  3. There is no need to specify DESC because the results are sorted in descending order by default
  4. None of the above
Answer: Answer is a

LAST_NAME  DEPTARTMENT_ID     SALARY
ALLEN                10                      3000
MILLER              20                     1500
King                   20                      2200
Davis                 30                      5000
Which of the following Subqueries work?

  1. SELECT * FROM employees where salary > (SELECT MIN(salary) FROM employees GROUP BY department_id);
  2. SELECT * FROM employees WHERE salary = (SELECT AVG(salary) FROM employees GROUP BY department_id);
  3. SELECT distinct department_id FROM employees Where salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id);
  4. SELECT department_id FROM employees WHERE SALARY > ALL (SELECT AVG(salary) FROM employees GROUP BY department_id);
  5. SELECT department_id FROM employees WHERE salary > ALL (SELECT AVG(salary) FROM employees GROUP BY AVG(SALARY));
Answer: Answer is a



  1. A primary key should be created for the customer_id field in the customer table and also for the customer_id field in the order table.
  2. A primary key should be created for the order_id field in the customer table and also for the customer_id field in the order table
  3. A primary key should be created for the customer_id field in the customer table and a foreign key should be created for the customer_id field in the order table
  4. A primary key should be created for the customer_id field in the customer table and a foreign key should be created for the order_id field in the order table
  5. None of these  
Answer: Answer is c

Begin Transaction
      Create table A ( x smallint, y smallint)
      Create table B ( p smallint, q smallint)

        Update A set x=600 where y > 700
        Update B set p=78 where q=99

          If @@ error != 0
          Begin
          RollBack Transaction
            Return 
          End

     Commit Transaction
Select the correct option:
  1. The transaction will work perfectly fine
  2. It will report an error
  3. The error handling routine contains a syntax error
  4. None of the above
  5. Both b and c
Answer: Answer is b
Further Reading:
It will report an error, because there is a space between @@ and error.

STUDENT_ID        INT 
SEMESTER_END        DATETIME 
GPA                FLOAT 
Which of the following statements finds the highest Grade Point Average (GPA) per semester?
  1. SELECT MAX(gpa) FROM student_grades WHERE gpa IS NOT NULL
  2. SELECT (gpa) FROM student_grades GROUP BY semester_end WHERE gpa IS NOT NULL
  3. SELECT MAX(gpa) FROM student_grades WHERE gpa IS NOT NULL GROUP BY semester_end
  4. SELECT MAX(gpa) GROUP BY semester_end WHERE gpa IS NOT NULL FROM student_grades
  5. SELECT MAX(gpa) FROM student_grades GROUP BY semester_end WHERE gpa IS NOT NULL
Answer: Answer is c

  1. DataRow
  2. DataSet
  3. DataTable
  4. DataReader
Answer: Answer is d

  1. customers( customer_id, customer_name)
  2. branch ( branch_id, branch_name )
What will be the output if the following query is executed:
Select *, branch_name from customers,branch
  1. It will return the fields customer_id, customer_name, branch_name
  2. It will return the fields customer_id, customer_name, branch_id, branch_name
  3. It will return the fields customer_id, customer_name, branch_id, branch_name, branch_name
  4. It will return an empty set since the two tables do not have any common field name
  5. It will return an error since * is used alone for one table only
Answer: Answer is c

  1. Select * from Products order by CurrentStock,ProductGroup
  2. Select * from Products order by CurrentStock DESC,ProductGroup
  3. Select * from Products order by ProductGroup,CurrentStock
  4. Select * from Products order by ProductGroup,CurrentStock DESC
  5. None of the above
Answer: Answer is d

  1. UPDATE Persons SET LastName = 'Nilsen' WHERE LastName = 'Hansen'
  2. UPDATE Persons SET LastName = 'Hansen' INTO LastName = 'Nilsen'
  3. SAVE Persons SET LastName = 'Nilsen' WHERE LastName = 'Hansen'
  4. SAVE Persons SET LastName = 'Hansen' INTO LastName = 'Nilsen'
Answer: Answer is a
Further Reading:
Useful resources, SQL UPDATE Statement

rollno        int 
name          varchar(20) 
course        varchar(20) 
What will be the query to display the courses in which the number of students enrolled is more than 5?
  1. Select course from students where count(course) > 5;
  2. Select course from students where count(*) > 5 group by course;
  3. Select course from students group by course;
  4. Select course from students group by course having count(*) > 5;
  5. Select course from students group by course where count(*) > 5;
  6. Select course from students where count(group(course)) > 5;
  7. Select count(course) > 5 from students;
  8. None of the above
Answer: Answer is d

select empno, DISTINCT ename, Salary from emp;
  1. EMPNO, unique value of ENAME and then SALARY are displayed
  2. EMPNO, unique value ENAME and unique value of SALARY are displayed
  3. DISTINCT is not a valid keyword in SQL
  4. No values will be displayed because the statement will return an error
Answer: Answer is d

  1. SELECT * FROM myTable WHERE column1 is null
  2. SELECT * FROM myTable WHERE column1 = null
  3. SELECT * FROM myTable WHERE column1 EQUALS null  
  4. SELECT * FROM myTable WHERE column1 NOT null  
  5. SELECT * FROM myTable WHERE column1 CONTAINS null
Answer: Answer is a


ProductID
ProductName
CurrentStock
MinimumStock
Two possible queries are: (a)select * from products where currentStock > MinimumStock + 50
(b)select * from products where currentStock - 50 > MinimumStock
  1. (a) is correct
  2. (b) is correct
  3. (a) and (b) both are correct
  4. (a) and (b) both are incorrect
Answer: Answer is d

  1. if...else
  2. if exists
  3. do...while
  4. while
  5. begin...end
Answer: Answer is e

LAST_NAME  DEPARTMENT_ID     SALARY
ALLEN                10                      3000
MILLER              20                     1500
King                   20                      2200
Davis                 30                      5000
Which of the following Subqueries will execute without any error?
  1. SELECT distinct department_id FROM employees Where salary = (SELECT AVG(salary) FROM employees GROUP BY department_id);
  2. SELECT distinct department_id FROM employees Where salary > (SELECT AVG(salary) FROM employees GROUP BY department_id);
  3. SELECT distinct department_id FROM employees Where salary > ANY (SELECT AVG(salary) FROM employees GROUP BY department_id);
  4. SELECT distinct department_id FROM employees Where salary > ALL (SELECT AVG(salary) FROM employees GROUP BY department_id);
  5. SELECT distinct department_id FROM employees Where salary < (SELECT AVG(salary) FROM employees GROUP BY department_id);
Answer: Answer is c, d

  1. CREATE [UNIQUE] INDEX index_name OF tbl_name (index_columns)
  2. CREATE [UNIQUE] INDEX OF tbl_name (index_columns)
  3. CREATE [UNIQUE] INDEX ON tbl_name (index_columns)
  4. CREATE [UNIQUE] INDEX index_name ON tbl_name (index_columns)
Answer: Answer is d
Further Reading:
Useful resources, SQL CREATE INDEX Statement

  1. Use Microsoft SQL Server indexes to optimize the data calculations
  2. Implement the calculations in a business layer class
  3. Implement the calculations in a data layer class
  4. Use Microsoft SQL Server stored procedures for the data calculations
Answer: Answer is a

  1. Begin a transaction
  2. Create a connection to the database
  3. Create a data set using an adapter object
  4. Use the data set to display data or to change items in the database
  5. Update the database from the data set
  6. Close the database connection
  7. Check for transaction errors
Answer: Answer is b, c, d, e, f

  1. Populate the data objects with data from the database. Populate the controls with values retrieved from the data objects.
  2. Populate the business objects with data from the database. Populate the controls with values retrieved from the business objects.
  3. Populate the data objects with data from the database. Populate the business objects with data from the data objects. Populate the controls with values retrieved from the business objects
  4. Bind the controls directly to the database.
Answer: Answer is c

  1. BLOB
  2. VARCHAR
  3. TEXT
  4. VARTEXT
Answer: Answer is d

  1. /* … */ are used for multiline comments
  2. // is used for single line comments
  3. – is used for single line comments
  4. Nested comments are allowed i.e. /* comment 1 /* comment 2 */ comment 1*/
  5. ‘ is used for single line comments
Answer: Answer is b, c, e

  1. Quarter
  2. dayofweek
  3. dayofyear
  4. weekday
Answer: Answer is a



  1. Table Name
  2. Database name
  3. LIMIT clause
  4. WHERE clause
  5. Column Names
Answer: Answer is a

  1. CHANGE TABLE
  2. MODIFY TABLE
  3. ALTER TABLE
  4. UPDATE TABLE
Answer: Answer is c

  1. SELECT * FROM Persons WHERE FirstName ORDER BY FirstName DESC
  2. SELECT * FROM Persons SORT REVERSE ‘FirstName’
  3. SELECT * FROM Persons ORDER BY ‘FirstName’
  4. SELECT * FROM Persons ORDER BY FirstName DESC
  5. SELECT * FROM Persons ORDER BY DESC FirstName
Answer: Answer is d

  1. Dec 31, 9999
  2. Jun 6, 2079
  3. Jan 1, 2753
  4. Jan 1, 2100
Answer: Answer is a

  1. desc myTable
  2. desc table myTable
  3. sp_columns myTable
  4. None of the above
  5. Using either option a or c
Answer: Answer is c

  1. Loss of data from employee sabotage
  2. Loss of data from any one corrupted table
  3. Recursive joins
  4. One-to-many or many-to-many relationships between columns in a table
  5. Data redundancy
Answer: Answer is d

  1. @@colcount
  2. @@error
  3. @@rowcount
  4. @@version
  5. All are valid global variables
Answer: Answer is e
Further Reading:
Useful resources, Global Variables in SQL Server

  1. BINARY
  2. VARBINARY
  3. BIT
  4. IMAGE
  5. TESTAMP
Answer: Answer is e
Share this article :

Post a Comment

 
Copyright © 2014. Mominul's Diary - All Rights Reserved
Developed by Mominul Islam