Latest MCTS 70-573 Dumps Real Exam Download 1-10

Ensurepass

QUESTION 1

You have a helper method named CreateSiteColumn that contains the following code segment.

private static void CreateSiteColumn(SPWeb web, string columnName){

}

You need to add a new site column of type Choice to a SharePoint site by using the helper method.

Which code segment should you include in the helper method?

 

 

A. SPField field = new SPFieldChoice(System.web.Lists[0].Fields, columnName);

B. web.Fields.Add(columnName, SPFieldType.Choice, true);

C. web.Lists[0].Fields.Add(columnName, SPFieldType.Choice, True);

D. web.Lists[0].Views[0].ViewFields.Add(columnName);

 

Correct Answer: B

Explanation/Reference:

MNEMONIC RULE: “web.Fields.Add”

SPFieldCollection.Add Method (String, SPFieldType, Boolean) http://msdn.microsoft.com/en-us/library/ms472869.aspx

 

 

QUESTION 2

You have a Web application that contains the following code segment.

private void CreatingSPSite()

{ SPSite siteCollection = null;try{

 siteCollection = new SPSite(“http://contoso.com”);

}

finally

{

}

}

You need to prevent the code segment from causing a memory leak.

Which code segment should you add?

 

 

A. if (siteCollection != null){

 siteCollection.Close();

}

B. if (siteCollection != null){

 siteCollection.Dispose();

}

C. siteCollection = null;

D. siteCollection.WriteLocked = false;

 

Correct Answer: B

Explanation/Reference:

MNEMONIC RULE: “Dispose of memory leak”

Difference between Close() and Dispose() Method http://dotnetguts.blogspot.com/2007/06/difference-between-close-and-dispose.html

 

 

QUESTION 3

You deploy a custom Web Part named WebPart1 to a SharePoint site.

WebPart1 contains the following code segment. (Line numbers are included for reference only.)

01 protected void Page_Load(object sender, EventArgs e)02 {

03 04 05 06 07 08  SPSite site = null;try{ SPSite site = new SPSite(“http://www.contoso.com/default.aspx”);SPWeb web = site.OpenWeb(); 

09   

10 11  }catch 

12 13  { 

14 15 16 17  }finally{ 

18  }

19 }

After you deploy WebPart1, users report that the pages on the site load slowly.

You retract WebPart1 from the site.

Users report that the pages on the site load without delay. You need to modify the code in WebPart1 to prevent the pages from loading slowly.

What should you do?

 

A. Add the following line of code at line 08:

site.ReadOnly = true;

B. Add the following line of code at line 13:

site.Dispose();

C. Add the following line of code at line 17:

site.Dispose();

D. Add the following line of code at line 17:

site.ReadOnly = true;

 

Correct Answer: C

Explanation/Reference: MNEMONIC RULE: “finally dispose”

Disposing Objects http://msdn.microsoft.com/en-us/library/ee557362.aspx

 

 

QUESTION 4

You have a Web Part that contains the following code segment. (Line numbers are included for reference only.)

01 protected void Page_Load(object sender, EventArgs e)02 {

clip_image002

A. Add the following line of code at line 06:

web.Close();

B. Add the following line of code at line 06:

web.Dispose();

C. Add the following line of code at line 06:

site.Close();

D. Change line 03 to the following code segment:

using (SPSite site = new SPSite(“http://www.contoso.com/default.aspx”))

 

Correct Answer: D

 

Explanation/Reference:

MNEMONIC RULE: “using statement”

You can automatically dispose SharePoint objects that implement the IDisposable interface by using the Microsoft Visual C# and Visual Basic using statement.

Disposing Objects http://msdn.microsoft.com/en-us/library/ee557362.aspx

 

 

QUESTION 5

You create an event receiver.

The ItemAdded method for the event receiver contains the following code segment. (Line numbers are included for reference only.)

01 SPWeb recWeb = properties.Web;

02 using (SPSite siteCollection = new SPSite(“http://site1/hr”))

03 {

04 using (SPWeb web = siteCollection.OpenWeb())

05 {

06 PublishingWeb oWeb = PublishingWeb.GetPublishingWeb(web);

07 PublishingWebCollection pubWebs = oWeb.GetPublishingWebs();

08 foreach (PublishingWeb iWeb in pubWebs)

09 {

10 try

11 {

12 SPFile page = web.GetFile(“/Pages/default.aspx”);

13 SPLimitedWebPartManager wpManager = page.GetLimitedWebPartManager

(PersonalizationScope.Shared);

14 }

15 finally

16 {

17 if (iWeb != null)

18 {

19 iWeb.Close();

20 }

21 }

22 }

23 }24 }

You need to prevent the event receiver from causing memory leaks.

Which object should you dispose of?

 

A. oWeb at line 06

B. recWeb at line 01

C. wpManager at line 13

D. wpManager.Web at line 13

 

Correct Answer: D

Explanation/Reference:

MNEMONIC RULE: “sneaky, sneaky wpManager.Web”

Gets the web that this Web Part Page is stored in.

SPLimitedWebPartManager.Web Property http://msdn.microsoft.com/en-us/library/ microsoft.sharepoint.webpartpages.splimitedwebpartmanager.web.aspx

 

 

QUESTION 6

You create a console application to manage Personal Sites.

The application contains the following code segment. (Line numbers are included for reference only.)

01 SPSite siteCollection = new SPSite(“http://moss”);

02 UserProfileManager profileManager = new UserProfileManager

(ServerContext.GetContext(siteCollection));

03 UserProfile profile = profileManager.GetUserProfile(“domain\username”);

04 SPSite personalSite = profile.PersonalSite;

05

06 siteCollection.Dispose();

You deploy the application to a SharePoint site.

After deploying the application, users report that the site loads slowly. You need to modify the application to prevent the site from loading slowly.

What should you do?

 

A. Remove line 06.

B. Add the following line of code at line 05:

personalSite.close();

C. Add the following line of code at line 05:

personalSite.Dispose();

D. Change line 06 to the following code segment:

siteCollection.close();

 

Correct Answer: C

Explanation/Reference: MNEMONIC RULE: “Dispose”

Disposing Objects http://msdn.microsoft.com/en-us/library/ee557362.aspx

 

 

QUESTION 7

You are creating a Web Part for SharePoint Server 2010.

The Web Part contains the following code segment. (Line numbers are included for reference only.)

01 protected override void CreateChildControls()

02 {

03 base.CreateChildControls();

04 SPSecurity.RunWithElevatedPrivileges(

05 delegate()

06 {

07 Label ListCount = new Label();

08 ListCount.Text = String.Format(“There are {0} Lists”,

SPContext.Current.Web.Lists.Count);

09 Controls.Add(ListCount);

10 });

11 }

You need to identify which line of code prevents the Web Part from being deployed as a sandboxed solution.

Which line of code should you identify?

 

A. 03

B. 04

C. 08

D. 09

 

Correct Answer: B

 

Explanation/Reference:

MNEMONIC RULE: “No RunWithElevatedPrivileges for sandboxed solutions”

Methods in a sandboxed solution cannot be configured to run with the elevated privileges of the user identity in which the application pool runs.

Restrictions on Sandboxed Solutions in SharePoint 2010 http://msdn.microsoft.com/en-us/library/gg615454.aspx

 

 

QUESTION 8

You have a SharePoint site collection. The root Web of the site collection has the URL http://intranet.

You plan to create a user solution that will contain a Web Part. The Web Part will display the title of the root Web.

You write the following code segment for the Web Part. (Line numbers are included for reference only.)

01 SPSite currentSite = new SPSite(“http://intranet”);

02

03 Label currentTitle = new Label();

04 currentTitle.Text = currentSite.RootWeb.Title;

You add the Web Part to a page in the root Web and receive the following error message: “Web Part Error: Unhandled exception was thrown by the sandboxed code wrapper’s Execute method in the partial trust app domain: An unexpected error has occurred.”

You need to prevent the error from occurring.

What should you do?

 

A. Add the following line of code at line 02:

currentSite.OpenWeb();

B. Add the following line of code at line 02:

currentSite.OpenWeb(“http://intranet”);

C. Change line 01 to the following code segment:

SPSite currentSite = SPContext.Current.Site;

D. Change line 04 to the following code segment:

currentTitle.Text = currentSite.OpenWeb().Title;

 

Correct Answer: C

Explanation/Reference:

MNEMONIC RULE: “sandboxed = SPContext”

OpenWeb() method returns SPWeb object, so answers A and B are incorrect, since they assume

OpenWeb() method doesn’t return an object.

Answer D is incorrect for the same reason.

This constructor is allowed in sandboxed solutions. in that case, the value of the requestUrl parameter must resolve to the parent site collection in which the sandboxed solution is deployed.

If the value of the requestUrl parameter resolves to the URL of any other site collection, the constructor throws an exception because a sandboxed solution is not allowed to access any SharePoint objects outside its hosting site collection.

SPSite Constructor (String)

http://msdn.microsoft.com/en-us/library/ms466911.aspx

 

 

QUESTION 9

You need to disable the CriticalExceptionCount measure for all user solutions.

You write the following code segment. (Line numbers are included for reference only.)

01 SPUserCodeService userCode = SPUserCodeService.Local;

02 SPResourceMeasureCollection measures = userCode.ResourceMeasures;

03 SPResourceMeasure measure = measures[“CriticalExceptionCount”];

04

05 measure.Update();

Which code segment should you add at line 04?

 

A. measure.AbsoluteLimit = 0;

B. measure.AbsoluteLimit = 1;

C. measure.ResourcesPerPoint = 0;

D. measure.ResourcesPerPoint = 1;

 

Correct Answer: C

Explanation/Reference:

MNEMONIC RULE: Zero ResourcesPerPoint

For example, AbnormalProcessTerminationCount has a ResourcesPerPoint value of 1. Every time a sandboxed solution terminates abnormally, 1 point is added. If you want to increase the penalty for a sandboxed solution that terminates, you can set ResourcesPerPoint to another value, such as 2. You can use 0 if you are not concerned about this metric.

SharePoint 2010 Sandboxed Solutions – Resource Quotas

http://sharepointinnovations.blogspot.com/2011/05/sharepoint-2010-sandboxed-solutions_06.html

 

 

QUESTION 10

You created a custom ASPX page that updates a list. The page is deployed to the _layouts folder.

The page contains the following code segment. (Line numbers are included for reference only.)

01 <form id=”Form1″ runat=”Server”> 02 <asp:Button id=”btnUpdate” runat=”server” Text=”Update”></asp:Button>03 </form>

A user attempts to update the list by using the page and receives the following error message: “The

security validation for this page is invalid”.

You need to prevent the error from occurring.

Which control should you include in Form1?

 

A. EncodedLiteral

B. FormDigest

C. InputFormCustomValidator

D. UIVersionedContent

 

Correct Answer: B

Explanation/Reference:

MNEMONIC RULE: “Digest your security”

FormDigest Class http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.formdigest.aspx

 

Download Lates MCTS 70-573 Real Free Tests , help you to pass exam 100%.