|
Microsoft 70-551 Exam - BestSheets.com Free 70-551 Sample Questions:
1. You are developing an application that stores data about your company's sales and technical support teams.
You need to ensure that the name and contact information for each person is available as a single collection when a user queries details about a specific team. You also need to ensure that the data collection guarantees type safety.
Which code segment should you use?
A. Hashtable team = new Hashtable();
team.Add(1, "Hance");
team.Add(2, "Jim");
team.Add(3, "Hanif");
team.Add(4, "Kerim");
team.Add(5, "Alex");
team.Add(6, "Mark");
team.Add(7, "Roger");
team.Add(8, "Tommy");
B. ArrayList team = new ArrayList();
team.Add("1, Hance");
team.Add("2, Jim");
team.Add("3, Hanif");
team.Add("4, Kerim");
team.Add("5, Alex");
team.Add("6, Mark");
team.Add("7, Roger");
team.Add("8, Tommy");
C. Dictionary<int, string> team =
new Dictionary<int, string>();
team.Add(1, "Hance");
team.Add(2, "Jim");
team.Add(3, "Hanif");
team.Add(4, "Kerim");
team.Add(5, "Alex");
team.Add(6, "Mark");
team.Add(7, "Roger");
team.Add(8, "Tommy");
D. string[] team =
new string[] {"1, Hance",
"2, Jim", "3, Hanif",
"4, Kerim", "5, Alex",
"6, Mark", "7, Roger",
"8, Tommy"};
Answer: C
2. Your Web site uses custom Themes. Your Web site must support additional Themes based on the user's company name.
The company name is set when a user logs on to the Web site. The company's Theme name is stored in a variable named ThemeName.
You need to use this variable to dynamically set the Web site's Theme.
What should you do?
A. Add the following code segment to the markup source of each page on the Web site.
<%@ Page Theme="ThemeName" ... %>
B. Add the following code segment to the Load event of each page on the Web site.
Page.Theme = ThemeName;
C. Add the following code segment to the PreInit event of each page on the Web site.
Page.Theme = ThemeName;
D. Add the following code segment to the Web site's configuration file.
<pages theme="ThemeName" />
Answer: C
3. You need to create a method to clear a Queue named q.
Which code segment should you use?
A. foreach (object e in q) {
q.Dequeue();
}
B. foreach (object e in q) {
Enqueue(null);
}
C. q.Clear();
D. q.Dequeue();
Answer: C
4. You are writing a custom dictionary. The custom-dictionary class is named MyDictionary.
You need to ensure that the dictionary is type safe.
Which code segment should you use?
A. class MyDictionary : Dictionary<string, string>
B. class MyDictionary : HashTable
C. class MyDictionary : IDictionary
D. class MyDictionary { ... }
Dictionary<string, string> t =
new Dictionary<string, string>();
MyDictionary dictionary = (MyDictionary)t;
Answer: A
5. You are creating an undo buffer that stores data modifications.
You need to ensure that the undo functionality undoes the most recent data modifications first. You also need to ensure that the undo buffer permits the storage of strings only.
Which code segment should you use?
A. Stack<string> undoBuffer = new Stack<string>();
B. Stack undoBuffer = new Stack();
C. Queue<string> undoBuffer = new Queue<string>();
D. Queue undoBuffer = new Queue();
Answer: A
6. You have an SQL query that takes one minute to execute. You use the following code segment to execute the SQL query asynchronously.
IAsyncResult ar = cmd.BeginExecuteReader();
You need to execute a method named DoWork() that takes one second to run while the SQL query is executing. DoWork() must run as many times as possible while the SQL query is executing.
Which code segment should you use?
A. while (ar.AsyncWaitHandle == null) {
DoWork();
}
dr = cmd.EndExecuteReader(ar);
B. while (!ar.IsCompleted) {
DoWork();
}
dr = cmd.EndExecuteReader(ar);
C. while (Thread.CurrentThread.ThreadState == ThreadState.Running) {
DoWork();
}
dr = cmd.EndExecuteReader(ar);
D. while (!ar.AsyncWaitHandle.WaitOne()) {
DoWork();
}
dr = cmd.EndExecuteReader(ar);
Answer: B
7. You need to write a code segment that will add a string named strConn to the connection string section of the application configuration file.
Which code segment should you use?
A. Dim myConfig As Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
myConfig.ConnectionStrings.ConnectionStrings.Add( _
New ConnectionStringSettings("ConnStr1", strConn))
myConfig.Save()
B. Dim myConfig As Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
myConfig.ConnectionStrings.ConnectionStrings.Add( _
New ConnectionStringSettings("ConnStr1", strConn))
ConfigurationManager.RefreshSection("ConnectionStrings")
C. ConfigurationManager.ConnectionStrings.Add( _
New ConnectionStringSettings("ConnStr1", strConn))
ConfigurationManager.RefreshSection("ConnectionStrings")
D. ConfigurationManager.ConnectionStrings.Add(
New ConnectionStringSettings("ConnStr1", strConn))
Dim myConfig As Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
myConfig.Save()
Answer: A
8. You are using the Microsoft Visual Studio 2005 IDE to examine the output of a method that returns a string. You assign the output of the method to a string variable named fName.
You need to write a code segment that prints the following on a single line
The message: "Test Failed: "
The value of fName if the value of fName does not equal "John"
You also need to ensure that the code segment simultaneously facilitates uninterrupted execution of the application.
Which code segment should you use?
A. Debug.Assert(fName = "John", "Test Failed: ", fName)
B. Debug.WriteLineIf(fName <> "John", _
fName, "Test Failed")
C. If fName <> "John" Then
Debug.Print("Test Failed: ")
Debug.Print(fName)
End If
D. If fName <> "John" Then
Debug.WriteLine("Test Failed: ")
Debug.WriteLine(fName)
End If
Answer: B
9. You are creating a class that performs complex financial calculations. The class contains a method named GetCurrentRate that retrieves the current interest rate and a variable named currRate that stores the current interest rate.
You write serialized representations of the class.
You need to write a code segment that updates the currRate variable with the current interest rate when an instance of the class is deserialized.
Which code segment should you use?
A. [OnSerializing]
internal void UpdateValue (StreamingContext context) {
currRate = GetCurrentRate();
}
B. [OnSerializing]
internal void UpdateValue(SerializationInfo info) {
info.AddValue("currentRate", GetCurrentRate());
}
C. [OnDeserializing]
internal void UpdateValue(SerializationInfo info) {
info.AddValue("currentRate", GetCurrentRate());
}
D. [OnDeserialized]
internal void UpdateValue(StreamingContext context) {
currRate = GetCurrentRate();
}
Answer: D
10. You create a master page named Article.master. Article.master serves as the template for articles on your Web site. The master page uses the following page directives.
<%@ Master Language="C#" Src="~/article.master.cs" Inherits="article" %>
You need to create a content page that uses the master page as a template. In addition, you need to use a single master page for all devices that access the Web site.
Which code segment should you use?
A. <%@ Page Language="C#" Theme="article"%>
B. <%@ Page Language="C#" MasterPageFile="~/article.master"%>
C. <%@ Page Language="C#" ie:MasterPageFile="~/article.master"%>
D. <%@Page Language="C#" all:MasterPageFile="~/article.master"%>
Answer: B
|
|