PrepAway - Latest Free Exam Questions & Answers

Author: seenagape

What should you do?

You create Microsoft Windows-based applications. You create an application that accesses data on a Microsoft SQL Server 2005 database. You write the following code segment. (Line numbers are included for reference only.)

01 private void LoadData()
02 {
04 cn.Open();
05 daProducts.Fill(ds);
06 daCategories.Fill(ds);
07 cn.Close();
09 }

The cn variable points to a SqlConnection object. The SqlConnection object will be opened almost every time this code segment executes. You need to complete this code segment to ensure that the application continues to run even if the SqlConnection object is open. You also need to ensure that the performance remains unaffected. What should you do?

Which design should you choose?

You create Web-based client applications.

You are creating a class library. The class library will be used to read and write data in the following three tables that are located in the Northwind database:

Customers
Orders
OrderDetails

The structure of the three tables is shown in the following diagram. (Refer to the Exhibit.) You need to ensure that the interfaces of the three classes accurately represent the connections between the tables in the database. Which design should you choose?

Which two actions should you perform?

You create Microsoft Windows-based applications. You are creating a component that will be used by several client applications. The component contains the following code segment. (Line numbers are included for reference only.)

01 namespace MyComponent {
02 public class Account {
03 private string mAccountNo;
04 private decimal mBalance;
05 public Account(string AcctNo) {
06 …
07 }
08 public void Withdraw(decimal Amount) {
09 …
10 }
11 public void Deposit(decimal Amount) {
12 …
13 }
14 }
15 public class SavingsAccount:Account {
16 public SavingsAccount(string AcctNo):base(AcctNo) {
17 …
18 }
19 public void ApplyInterestRate(decimal Amount) {
20 …
21 }
22 }
23 }
You need to redesign the Account class and the SavingsAccount class to meet the following requirements:

Developers must not be able to instantiate the Account class from client applications. Developers must not be able to extend the functionality of the SavingsAccount class. Developers must be able to instantiate the SavingsAccount class from client applications.

Which two actions should you perform? (Each correct answer presents part of the solution. Choose two).

Which code segment should you use?

You create components for Web-based client applications. You are creating a BankAccount class. The BankAccount class contains an AccountNumber property and a CreateAccount method. The CreateAccount method is used to create a new account. The method generates a unique random value for the actNumber field. You need to ensure that the BankAccount class is extendable, and that it serves as the base class for other derived classes. You also need to ensure that each derived class can have its own guidelines to generate account numbers in the CreateAccount method. Which code segment should you use?