Tuesday, July 14, 2009

Free Sample Questions 70-562(CSharp), 70-562 braindumps, 70-562 study guide, 70-562 ebook

Microsoft 70-562(CSharp) Exam - Cheat-Test.com

Free 70-562(CSharp) Sample Questions:


Q: 1 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named Wiikigo.
You use the Microsoft .NET Framework version 3.5 to create a Microsoft ASP.NET Web application.
The application must redirect the original URL to a different ASPX page. You must make sure that after the page is executed, the users cannot view the original URL. Besides this, you must make sure that only one request from the client browser is required by each page execution requires. So what action should you perform to achieve the two goals?
A. You should transfer execution to the correct ASPX page by using the HttpContext.Current.RewritePath method.
B. Add the Location: new URL value to the Response.Headers collection. Call the Response.End() statement.
Send the header to the client computer to transfer execution to the correct ASPX page.
C. You should transfer execution to the correct ASPX page by using the Server.Transfer method.
D. You should transfer execution to the correct ASPX page by using the Response.Redirect method.
Answer: A

Q: 2 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named Wiikigo. You use the Microsoft .NET Framework version 3.5 to create a Microsoft ASP.NET Web application. A Web page is created. The Web page contains the following two XML fragments. (Line numbers are used for reference only.)
1

4

8
9
10
11 Text='<%# Eval("WireAmount") %>' />
12
13

From a Microsoft SQL Server 2005 database table which has a column named WireAmount , the SqlDataSource1 object retrieves the data. Now you receive an order from your company CIO, according to his requirement, the column must be displayed in red color when the size of the WireAmount column value is greater than seven characters. The CIO assigns this task to you that you must make sure of this. So what action should you perform?
A. Insert the following code segment at line 06. OnDataBound="FmtClr" Insert the following code segment at line 02. protected void FmtClr(object sender, EventArgs e){ Label WireAmount = new Label(); WireAmount.ID = "WireAmountLabel"; if ( WireAmount.Text.Length > 7)
{WireAmount.ForeColor = Color.Red; } else {WireAmount.ForeColor = Color.Black; }}
B. Insert the following code segment at line 06. OnItemDataBound="FmtClr" Insert the following code segment at line 02. protected void FmtClr(object sender, ListViewItemEventArgs e){ Label WireAmount = (Label) e.Item.FindControl("WireAmountLabel"); if ( WireAmount.Text.Length > 7) { WireAmount.ForeColor = Color.Red; } else {WireAmount.ForeColor = Color.Black; }}
C. Insert the following code segment at line 06. OnItemDataBound="FmtClr" Insert the following code segment at line 02. protected void FmtClr(object sender, ListViewItemEventArgs e){ Label WireAmount = (Label) e.Item.FindControl("WireAmount"); if ( WireAmount.Text.Length > 7)
{WireAmount.ForeColor = Color.Red; } else {WireAmount.ForeColor = Color.Black; } }
D. Insert the following code segment at line 06. OnDataBinding="FmtClr" Insert the following code segment at line 02. protected void FmtClr(object sender, EventArgs e){ Label WireAmount = new Label(); WireAmount.ID = "WireAmount"; if ( WireAmount.Text.Length > 7)
{WireAmount.ForeColor = Color.Red; } else { WireAmount.ForeColor = Color.Black; }}
Answer: B

Q: 3 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named Wiikigo. You use the Microsoft .NET Framework version 3.5 to create a Microsoft ASP.NET Web application. Two user controls are created by you. They are respectivley named UCtrlA.ascx and UCtrlB.ascx. The user controls postback to the server.
You create a new Web page that has the following ASPX code. You create a new Web page that has the following ASPX code.


You write the following code segment for the Web page for dynamically creating the user controls.
public void LoadControls()
{
if (ViewState["CtrlA"] != null)
{
Control c;
if ((bool)ViewState["CtrlA"] == true)
{ c = LoadControl("UCtrlA.ascx"); }
else
{ c = LoadControl("UCtrlB.ascx"); }
c.ID = "Ctrl";
PlHolder.Controls.Add(c);
}
}
protected void Chk_CheckedChanged(object sender, EventArgs e)
{
ViewState["CtrlA"] = Chk.Checked;
PlHolder.Controls.Clear();
LoadControls();
}
According to the requirement of the company CIO, the user control that is displayed must be recreated during postback and retains its state. You have been assigned this task to make sure of this.
Which method should be added to the Web page?
A. protected override void OnLoadComplete(EventArgs e){ base.OnLoadComplete(e); LoadControls();}
B. protected override object SaveViewState(){ LoadControls(); return base.SaveViewState();}
C. protected override void LoadViewState(object savedState){ base.LoadViewState(savedState); LoadControls();}
D. protected override void Render(HtmlTextWriter writer){ LoadControls(); base.Render(writer);}
Answer: C

Q: 4 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named Wiikigo.
You use the Microsoft .NET Framework version 3.5 to create a Microsoft ASP.NET Web application.
You write the code fragment below. (Line numbers are used for reference only.)
1

6
7

8
9
Now you receive an e-mail from your company CIO, according to his requirement, the error message must also be displayed in the validation summary list if it is displayed in the validation control.
The company CIO assigns this task to you. So what should you do to make sure of this?
A. The following code segment should be added to line 04. ErrorMessage="Required text in TextBox1"
B. The following code segment should be added to line 06. Required text in TextBox1
C. The following code segment should be added to line 04. Text="Required text in TextBox1" ErrorMessage="ValidationSummary1"
D. The following code segment should be added to line 04. Text="Required text in TextBox1"
Answer: A

Q: 5 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named Wiikigo.
You use the Microsoft .NET Framework version 3.5 to create a Microsoft ASP.NET Web application.
You write the code fragment below.





You must make sure that when you click the Button1 control, a selected list of items move from the ListBox1 control to the ListBox2 control when you click the Button1 control.
Of the following code segments, which one should be used?
A. foreach (ListItem li in ListBox1.Items) { if (li.Selected) { li.Selected = false; ListBox2.Items.Add(li);
ListBox1.Items.Remove(li); }}
B. foreach (ListItem li in ListBox1.Items) { if (li.Selected) { ListBox2.Items.Add(li);
ListBox1.Items.Remove(li); }}
C. foreach (ListItem li in ListBox1.Items) { if (li.Selected) { li.Selected = false; ListBox2.Items.Add(li);
}}foreach (ListItem li in ListBox1.Items) { if (ListBox2.Items.Contains(li))
ListBox1.Items.Remove(li);}
D. foreach (ListItem li in ListBox1.Items) { if (li.Selected) { li.Selected = false; ListBox2.Items.Add(li);
}}foreach (ListItem li in ListBox2.Items) { if (ListBox1.Items.Contains(li))
ListBox1.Items.Remove(li);}
Answer: D

Q: 6 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named Wiikigo. You use the Microsoft .NET Framework version 3.5 to create a Microsoft ASP.NET Web application. You create a file named movies.xml that contains the following code fragment.











A Web form is added to the application.
You write the following code segment in the Web form. (Line numbers are used for reference only.)
1


2
6
7

According to the requirement of the company, you have to implement the XmlDataSource control to display the XML data in a TreeView control.
At line 6, which code segment should be inserted?
A.



B.


C.


D.


Answer: C

Q: 7 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named Wiikigo. You use the Microsoft .NET Framework version 3.5 to create a Microsoft ASP.NET Web application. Look at the code fragment below.




You use the above code fragment to create a login Web form.
The login() client-side script is called to authenticate the user when a user clicks the btnLogin Button control. The credentials provided in the TextBox controls are used to call the client-side script.
Look at the following code fragment:
01


The above client-script code fragment is also added in the Web form by you. You configure the ASP.NET application to use Forms Authentication. The ASP.NET AJAX authentication service is activated in the Web.config file.
You must make sure that you can achieve this following two requirements: If authentication succeeds, the onLoginCompleted client-script function is called to notify the user; If authentication fails, the onLoginFailed client-script function is called to display an error message.
At line6, which code segment should be inserted?
A. var auth =
Sys.Services.AuthenticationService;auth.set_defaultLoginCompletedCallback(onLoginCompleted);try {
auth.login(username, password, false, null, null, null, null, null); }catch
(err) { onLoginFailed(err, null, null);}
B. var auth = Sys.Services.AuthenticationService; auth.login(username, password, false, null,
null,onLoginCompleted, onLoginFailed, null);
C. var auth = Sys.Services.AuthenticationService;try { var validCredentials = auth.login(username, password,
false, null, null, null, null, null); if (validCredentials)
onLoginCompleted(true, null, null); else onLoginCompleted(false, null, null);}catch (err) { onLoginFailed(err,
null, null);}
D. var auth = Sys.Services.AuthenticationService; auth.set_defaultFailedCallback(onLoginFailed);var
validCredentials = auth.login(username, password, false, null, null, null, null, null);if
(validCredentials)onLoginCompleted(true, null, null);elseonLoginCompleted(false, null, null);
Answer: B

Q: 8 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named Wiikigo. You use the Microsoft .NET Framework version 3.5 to create a Microsoft ASP.NET Web application. You intend to add a custom parameter in the SqlDataSource control.
You write the following code fragment.







In order to create a custom parameter class, you write the following code segment.
public class DayParameter : Parameter {
}
You must make sure that the current date and time is returned by the custom parameter.
Of the following code segments, which code segment should be added to the DayParameter class?
A. protected override Parameter Clone(){ Parameter pm = new DayParameter(); pm.DefaultValue =
DateTime.Now; return pm;}
B. protected DayParameter(): base("Value", TypeCode.DateTime, DateTime.Now.ToString()){}
C. protected override void LoadViewState(object savedState){ ((StateBag)savedState).Add("Value",
DateTime.Now);}
D. protected override object Evaluate(HttpContext context, Control control) { return DateTime.Now;}
Answer: D

Q: 9 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named Wiikigo. You use the Microsoft .NET Framework version 3.5 to create a Microsoft ASP.NET Web application. The application contains a Web form file named TVReviews.aspx and has DetailsView control named DetailsView01. The TVReviews.aspx file connects to a LinqDataSource DataSource named LinqDataSource01. LinqDataSource01has a primary key named TVID.
The TVReviews.aspx file contains the following code fragment. (Line numbers are used for reference only.)
1
5
6
9
11
13
15

16
The company CIO assigns a task to you. According to his requirement, you must make sure that the users can insert and update content in the DetailsView1 control. Besides this, you have to prevent duplication of the link button controls for the Edit and New operations.
At line 3, which code segment should be inserted?
A. AllowPaging="true"AutoGenerateDeleteButton="false"AutoGenerateEditButton="true" AutoGenerateInsertButton=
B. AllowPaging="false"AutoGenerateRows="false"
C. AllowPaging="false"AutoGenerateDeleteButton="false"AutoGenerateEditButton="true" AutoGenerateInsertButton=
D. AllowPaging="true"AutoGenerateRows="false"DataKeyNames="IVID"
Answer: D

Q: 10 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named Wiikigo.
You use the Microsoft .NET Framework version 3.5 to create a Microsoft ASP.NET Web application which contains a Web form with a Label control named lblPrice . You define the following class.
public class Product {
public decimal Price { get; set; }
}
Look at the XML fragment below. You access the fragment by using a StringReader variable named
xmlStream.

35

Now you get an e-mail from your company manager, the manager wants to view the price of the product, so you have to display the price of the product from the XML fragment in the lblPrice Label control.
Of the following code segments, which one should be used?
A. XmlSerializer xs = new XmlSerializer(typeof(Product));Product boughtProduct =
xs.Deserialize(xmlStream) as Product;lblPrice.Text = boughtProduct.Price.ToString();
B. XmlDocument xDoc = new XmlDocument();xDoc.Load(xmlStream);Product boughtProduct =
xDoc.OfType().First();lblPrice.Text = boughtProduct.Price.ToString();
C. DataTable dt = new DataTable();dt.ExtendedProperties.Add("Type",
"Product");dt.ReadXml(xmlStream);lblPrice.Text = dt.Rows[0]["Price"].ToString();
D. XmlReader xr = XmlReader.Create(xmlStream);Product boughtProduct =
xr.ReadContentAs(typeof(Product), null) as Product;lblPrice.Text = boughtProduct.Price.ToString();
Answer: A

Q: 11 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named Wiikigo.
You use the Microsoft .NET Framework version 3.5 to create a Microsoft ASP.NET Web application.
You create a custom Web user control which will be compiled as a library. You name it JoinedControl. Look at the following code segment. (Line numbers are used for reference only.)
1 protected override void OnInit(EventArgs e)
2 {
3 base.OnInit(e);
4
5 }
You write the above code segment for the JoinedControl control.
In the ASP.NET application, all the master pages contain the following directive.
<%@ Master Language="C#" EnableViewState="false" %>
You must make sure that the state of the SharedControl control can persist on the pages that reference a master page.
At line 4, which code segment should be inserted?
A. Page.RegisterStartupScript("SharedControl","server");
B. Page.RegisterRequiresPostBack(this);
C. Page.UnregisterRequiresControlState(this);
D. Page.RegisterRequiresControlState(this);
Answer: D

Q: 12 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named Wiikigo.
You use the Microsoft .NET Framework version 3.5 to create a Microsoft ASP.NET Web application.
You write the code fragment below:









According to the requirement of the company CIO, each Label control value must be asynchronously updatable when you click the btnSubmit Button control.
Of the following options, which code segment should be used?
A. protected void btnSubmit_Click(object sender, EventArgs e){ Label1.Text = "Label1 updated value";
Label2.Text = "Label2 updated value";
ScriptManager1.RegisterAsyncPostBackControl(Label3); Label3.Text = "Label3 updated value";}
B. protected void btnSubmit_Click(object sender, EventArgs e){ Label1.Text = "Label1 updated value";
Label2.Text = "Label2 updated value"; Label3.Text = "Label3 updated value";}
C. protected void btnSubmit_Click(object sender, EventArgs e){ Label1.Text = "Label1 updated value";
Label2.Text = "Label2 updated value"; ScriptManager1.RegisterDataItem(Label3,
"Label3 updated value");}
D. protected void btnSubmit_Click(object sender, EventArgs e){ ScriptManager1.RegisterDataItem(Label1,
"Label1 updated value"); ScriptManager1.RegisterDataItem(Label2, "Label2 updated
value"); Label3.Text = "Label3 updated value";}
Answer: C

Q: 13 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named Wiikigo.
You use the Microsoft .NET Framework version 3.5 to create a Microsoft ASP.NET Web application which uses ASP.NET AJAX. According to the company requirement, this application has to be deployed in a Web farm environment. For the application, SessionState has to be configured. Which code fragment should you use?
A.
B.
C.
D.
Answer: C

Q: 14 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named Wiikigo.
You use the Microsoft .NET Framework version 3.5 to modify an existing Microsoft ASP.NET application. After a theme is added to the ASP.NET application, you have to apply the theme to override any settings of individual controls. What action should you perform?
A. A master page should be added to the application. The StyleSheetTheme attribute should be set to the name of the theme in the @Master directive.
B. A master page should be added to the application. The Theme attribute should be set to the name of the theme in the @Master directive.
C. You should set the Theme attribute of the pages element to the name of the theme in the Web.config file of the application.
D. You should set the StyleSheetTheme attribute of the pages element to the name of the theme in the Web.config file of the application.
Answer: C

Q: 15 You are an application developer and you have about two years experience in developing Web-based applications by using Microsoft ASP.NET. Now you are employed in a company named
Wiikigo. You use the Microsoft .NET Framework version 3.5 to create a Microsoft ASP.NET Web application.
A class is created by you. The class contains the following code segment. (Line numbers are used for reference only.)
1 public object GetCachedProducts(sqlConnection conn) {
2
3 if (Cache["products"] == null) {
4 SqlCommand cmd = new SqlCommand(
5 "SELECT * FROM Products", conn);
7 conn.Open();
8 Cache.Insert("products", GetData(cmd));
9 conn.Close();
10 }
11 return Cache["products"];
12 }
13
14 public object GetData(SqlCommand prodCmd) {
15
16 }
The GetCachedProducts method is called to provide this list from the Cache object once a Web form has to access a list of products.
According to the requirement of the company CIO, the list of products must be always available in the Cache object. You are asked to make sure of this.
At line 15, which code segment should be inserted?
A. return prodCmd.ExecuteReader();
B. SqlDataAdapter da = new SqlDataAdapter(prodCmd);DataSet ds = new DataSet();da.Fill(ds);return ds;
C. SqlDataReader dr;prodCmd.CommandTimeout = int.MaxValue;dr = prodCmd.ExecuteReader();return dr;
D. SqlDataAdapter da = new SqlDataAdapter();da.SelectCommand = prodCmd;DataSet ds = new
DataSet();return ds.Tables[0];
Answer: B