Microsoft UPG:Transition MCPD.NET Frmwrk 3.5 Web Dev to 4 Web Dev Sample Questions:
1. You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application. You are
creating the data layer of the application. You write the following code segment. (Line numbers are included
for reference only.)
01 public static SqlDataReader GetDataReader(string sql){
02 SqlDataReader dr;
03
04 return dr;
05 }
You need to ensure that the following requirements are met:
*The SqlDataReader returned by the GetDataReader method can be used to retrieve rows from the
database.
*SQL connections opened within the GetDataReader method will close when the SqlDataReader is closed.
Which code segment should you insert at line 03?
A) SqlConnection cnn=new SqlConnection(strCnn); SqlCommand cmd =new SqlCommand(sql, cnn); cnn.Open(); try {
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
catch {
cnn.Close();
throw;
}
B) using (SqlConnection cnn=new SqlConnection(strCnn)){
try {
SqlCommand cmd =new SqlCommand(sql, cnn);
cnn.Open();
dr = cmd.ExecuteReader();
}
catch {
throw;
}
}
C) SqlConnection cnn=new SqlConnection(strCnn); SqlCommand cmd =new SqlCommand(sql, cnn); cnn.Open(); try {
dr = cmd.ExecuteReader();
cnn.Close();
}
catch {
throw;
}
D) SqlConnection cnn=new SqlConnection(strCnn); SqlCommand cmd =new SqlCommand(sql, cnn); cnn.Open(); try {
dr = cmd.ExecuteReader();
}
finally {
cnn.Close();
}
2. You are implementing an ASP.NET Web page.
You need to add a text box that allows only values between 1 and 10, inclusive, to be submitted. Which two
code segments should you use? (Each correct answer presents part of the solution. Choose two.)
A) <asp:TextBox ID="txt1" runat="server" onChange="validate_value(this, args)" />
B) <script type="text/javascript"> function validate_value(obj, args) { args.IsValid = (args.Value >= 1 && args.Value <= 10); } </script>
C) <script type="text/javascript"> function validate_value(obj, args) { return (args.Value >= 1 && args.Value <= 10); } </script>
D) <asp:TextBox ID="txt1" runat="server" /> <asp:CustomValidator ID="val1" runat="server" ControlToValidate="txt1" ClientValidationFunction="validate_value" ErrorMessage="Value invalid" />
3. You are designing a user input form that is part of an ASP.NET Web Forms application. You need to ensure that users cannot attack the Web server by submitting invalid data. Which approach should you recommend?
A) Write an onSubmit JavaScript handler that validates all form input.
B) Install a certificate on the Web server, and force all Web traffic to use SSL.
C) Write an OnClick method for the Submit button that rejects form submissions that contain invalid data.
D) Write an onSubmit JavaScript handler that URL-encodes all data that is passed to the server.
4. You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4 to create an application.
The application contains the following code segment. (Line numbers are included for reference only.)
01 class DataAccessLayer
02 {
03 private static string connString;
04
05 ...
06 public static DataTable GetDataTable(string command){
07
08 ...
09 }
10 }
You need to define the connection life cycle of the DataAccessLayer class. You also need to ensure that
the application uses the minimum number of connections to the database.
What should you do?
A) Replace line 01 with the following code segment.
class DataAccessLayer : IDisposable
Insert the following code segment to line 04.
private SqlConnection conn = new SqlConnection(connString);
public void Open(){
conn.Open();
}
public void Dispose(){
conn.Close();
}
B) Insert the following code segment at line 07. using (SqlConnection conn = new SqlConnection(connString)){
conn.Open();
}
C) Insert the following code segment at line 04. private static SqlConnection conn = new SqlConnection(connString); public static void Open(){
conn.Open();
}
public static void Close(){
conn.Close();
}
D) Insert the following code segment at line 04. private SqlConnection conn = new SqlConnection(connString); public void Open(){
conn.Open();
}
public void Close(){
conn.Close();
}
5. You are moving a Windows Communication Foundation (WCF) service into production.
You need to be able to monitor the health of the service. You only want to enable all performance counter
instances exposed by the ServiceModelService 4.0.0.0 counter group.
Which element should you add to the system.serviceModel section in the application configuration file?
A) <diagnostics performanceCounters="ServiceOnly" />
B) <diagnostics wmiProviderEnabled="true" performanceCounters="Off" />
C) <diagnostics wmiProviderEnabled="true" />
D) <diagnostics performanceCounters="All" />
Solutions:
| Question # 1 Answer: A | Question # 2 Answer: B,D | Question # 3 Answer: C | Question # 4 Answer: B | Question # 5 Answer: A |
We're so confident of our products that we provide no hassle product exchange.


By Maximilian

