Shared Flashcard Set

Details

70-573 new
70-573 new
50
Software
Professional
11/19/2012

Additional Software Flashcards

 


 

Cards

Term
QUESTION 1 You use a third-party site definition to create SharePoint sites. You need to add a Web Part to the home page of the site definition. Which file should you modify?

A. default.master
B. Onet.xml
C. Sp.xml
D. web.config
Definition
B
Term
QUESTION 2
You have a custom site definition. You create a custom site Feature. You need to ensure that the Feature is activated for all new sites that are created by using the custom site definition. What should you do?

A. Modify the Onet.xml file.
B. Modify the web.config file.
C. Add a Feature receiver to the custom site Feature.
D. Add a Feature dependency to the custom site Feature.
Definition
A
Term
QUESTION 3
You create a custom site definition named DCS. You create a site provision handler for DCS. DCS contains a file named DCSTemplate.xsd that stores configuration data. You need to read the content of DCSTemplate. xsd in the site provision handler.

Which property should you use?
A. SPSite.GetCustomWebTemplates(1033)["DCS"].ProvisionClass

B. SPWebApplication.DataRetrievalProvider

C. SPWebProvisioningProperties.Data

D. SPWebProvisioningProperties.Web.DataRetrievalServicesSettings
Definition
C
Term
QUESTION 4
You create custom code to import content to SharePoint sites. You create a custom site definition by using
Microsoft Visual Studio 2010. You need to ensure that when a new site that uses the site definition is created,
the custom code executes after the site is created.

Which class should you add to the project?
A. SPChangeFile
B. SPItemEventReceiver
C. SPWebEventReceiver
D. SPWebProvisioningProvider
Definition
D
Term
QUESTION 5

You create a custom Web Part.
You need to verify whether the Web Part causes any memory leaks.
Which tool should you use?


A. SPDisposeCheck.exe
B. SPMetal.exe
C. Wca.exe
D. WinDbg.exe
Definition
A
Term
QUESTION 6

You are creating a Web Part that will be deployed as a sandboxed solution. You need to ensure that the Web
Part can write debugging information to the SharePoint trace logs.
Which class should the logging component inherit?


A. SPDelegate
B. SPLog
C. SPPersistedObject
D. SPProxyOperation
Definition
D
Term
QUESTION 7

You update a solution validator.
You need to ensure that all SharePoint solutions are validated the next time the solutions are executed.
What should you do?


A. Modify the Guid attribute of the solution validator.
B. Deactivate and activate all of the installed solutions.
C. Modify the Signature property of the solution validator.
D. In the Feature that deploys the solution validator, modify the Version attribute of the Feature element.
Definition
C
Term
QUESTION 8

You are creating a Web Part. The Web Part will be used in a SharePoint subsite that has the URL http://www.
contoso.com/hr.
You need to ensure that the Web Part activates a Feature in the subsite without causing a memory leak.
Which code segment should you use?


A. Dim featuresCollect As SPFeatureCollection = SPContext.Current.SiteFeatures featuresCollect.Add(New
Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), True)

B. Dim featuresCollect As SPFeatureCollection = SPContext.Current.WebFeatures featuresCollect.Add(New
Guid("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"), True)
C. Dim web As New SPSite("http://www.contoso.com/hr")
Dim featureCollect As SPFeatureCollection = web.Features featureCollect.Add(New Guid("xxxxxxxxxxxx-
xxxx-xxxx-xxxxxxxxxxxx"), True)
D. Dim web As SPWeb = New SPSite("http://www.contoso.com/hr").OpenWeb() Dim featureCollect As
SPFeatureCollection = web.Features featureCollect.Add(New Guid("xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx"),
True)
Definition
B
Term
QUESTION 9

You create a Web Part that takes three values from three text boxes and creates a new SharePoint site when
you click a button named CreateNewSite.
The Web Part contains the following code segment.
Protected Sub CreateNewSite_Click(ByVal sender As Object, ByVal e As EventArgs)


Dim site As SPSite = SPContext.Current.Site


Dim web As SPWeb = site.AllWebs.Add(SiteNameTextBox.Text, SiteTitleTextBox.Text,
SiteDescriptionTextBox.Text, 0, SPWebTemplate.WebTemplateSTS, False, _False)
End Sub
You test the Web Part and it works properly.
When another user attempts to use the Web Part to create a new site, he receives the following error
message: "Error: Access Denied."
You need to ensure that users can use the Web Part to create new sites.
What should you do?


A. Add web.Update() after the code segment.
B. Add web.ValidatesFormDigest() after the code segment.
C. Run the code segment inside a SPSecurity.RunWithElevatedPrivileges delegate.
D. Add the following code after the code segment.
Dim currentUser As SPUser = web.CurrentUser
web.Users.Add(currentUser.LoginName, currentUser.Email, currentUser.Name, "")
Definition
C
Term
QUESTION 10

You have a SharePoint site collection that contains 100 subsites. You plan to create a Web Part. The Web
Part will be deployed to each subsite. You need to ensure that the Web Part retrieves all of the files in the root
directory of the current subsite. You write the following code segment. (Line numbers are included for
reference only.)
01Dim site As SPSite = SPContext.Current.Site
02Dim web As SPWeb = SPContext.Current.Web
Which code segment should you add at line 03?

A.
site.AllWebs[1].Files
B. Site.RootWeb.Lists[0].Items
C.
web.Files
D.
web.RootFolder.SubFolders[0].Files web.Users.Add(currentUser.LoginName, currentUser.Email,
currentUser.Name, "")
Definition
C
Term
QUESTION 11

You have a SharePoint site that has the URL http://contoso.com/hr.
You are creating a new Web Part.
You need to create a reference to the current subsite without having to dispose of any returned objects.
Which code segment should you use?


A. Dim siteCollection As New SPSite("http://www.contoso.com") Dim site As SPWebCollection =
siteCollection.AllWebs
B. Dim siteCollection As New SPSite("http://www.contoso.com") Dim site As SPWeb = siteCollection.
RootWeb
C. Dim site As SPSite = SPContext.Current.Site
D. Dim site As SPWeb = SPContext.Current.Web
Definition
D
Term
UESTION 12

You create a Feature named Feature1. Feature1 is activated in a SharePoint site.
You create a Web Part that contains the following code.
Dim site As New SPSite("http://intranet/site1")
Dim web As SPWeb = site.OpenWeb()
Dim feature As SPFeatureDefinition = SPFarm.Local.FeatureDefinitions("Feature1")
You need to modify the Web Part to activate Feature1 in Site1 only.
Which code segment should you add to the Web Part?


A. site.Features.Add(feature.Id)
B. site.WebApplication.WebService.Features.Add(feature.Id)
C. web.Features.Add(feature.Id)
D. web.Site.WebApplication.WebService.Features.Add(feature.Id)
Definition
A
Term
QUESTION 13

You have a SharePoint farm that has more than 100 custom Features.
You upgrade several Features in the farm.
You need to ensure that the site collection uses the most up-to-date versions of the Features. Only Features
that require an upgrade must be evaluated.
Which code segment should you use?


A. Dim webServices As New SPWebServiceCollection(SPFarm.Local)
For Each myWebService1 As SPWebService In webServices
Dim queryResults As SPFeatureQueryResultCollection = myWebService1.QueryFeatures
(SPFeatureScope.Site, True)
Dim featureEnumerator As IEnumerator(Of SPFeature) = queryResults.GetEnumerator() While
featureEnumerator.MoveNext()
Dim feature As SPFeature = featureEnumerator.Current
feature.Upgrade(False)


End While
Next



B. Dim webServices As New SPWebServiceCollection(SPFarm.Local)
For Each myWebService1 As SPWebService In webServices
Dim queryResults As SPFeatureQueryResultCollection =myWebService1.QueryFeatures
(SPFeatureScope.Web, True)
Dim featureEnumerator As IEnumerator(Of SPFeature) = queryResults.GetEnumerator() While
featureEnumerator.MoveNext()
Dim feature As SPFeature = featureEnumerator.Current
feature.Upgrade(False)


End While
Next


C. Dim site As SPSite = SPContext.Current.Site
Dim allFeatures As SPFeatureCollection = site.Features
For Each currentFeature As SPFeature In allFeatures
currentFeature.Upgrade(True)
Next


D. Dim web As SPWeb = SPContext.Current.Web
Dim allFeatures As SPFeatureCollection = web.Features
For Each currentFeature As SPFeature In allFeatures
currentFeature.Upgrade(True)
Next
Definition
A
Term
QUESTION 14

You are creating an application.
You develop a custom control that renders a contextual tab. The control contains the following code segment.
(Line numbers are included for reference only.) 01Protected Overloads Overrides Sub OnPreRender(ByVal e
As EventArgs)
02 Dim curRibbon As SPRibbon = SPRibbon.GetCurrent(Me.Page)
03
04 curRibbon.MakeContextualGroupInitiallyVisible("SP.Ribbon.ContextualGroup", String.Empty)
05 MyBase.OnPreRender(e)
06End Sub
You need to ensure that when the custom control is rendered, the custom contextual tab appears in the
Ribbon.
Which code segment should you add at line 03?


A. curRibbon.Enabled = true
B. curRibbon.MakeRTEContextualTabsAvailable("SP.Ribbon.ContextualTab ")
C. curRibbon.MakeTabAvailable("SP.Ribbon.ContextualTab")
D. curRibbon.Visible = true
Definition
C
Term
QUESTION 15
You need to create a Web Part that hides the out-of-the-box Ribbon on the current page.
Which code segment should you include in the Web Part?
A. SPRibbon.GetCurrent(me.Page).CommandUIVisible = false
B. SPRibbon.GetCurrent(me.Page).Dispose()
C. me.Page.FindControl("SPRibbon").Dispose()
D. me.Page.FindControl("SPRibbon").Visible = false
Definition
A
Term
QUESTION 16

You have a custom theme named MyTheme. The theme is defined in a file named MyTheme.thmx. You have
a console application that contains the following code segment. (Line numbers are included for reference
only.)
01Using site As New SPSite("http://intranet")
02Dim web As SPWeb = site.OpenWeb()
03...
04End Using
You need to programmatically apply the theme to a SharePoint site. Which code segment should you add to
the console application?


A. ThmxTheme.SetThemeUrlForWeb(web, "/_catalogs/theme/MyTheme.thmx", False)
B. web.AlternateCssUrl = "/_themes/MyTheme"
C. web.ApplyWebTemplate("MyTheme.thmx")
D. web.ThemedCssFolderUrl = "/_themes/MyTheme"
Definition
A
Term
QUESTION 17

You plan to develop a Web Part that displays a SharePoint list.

The Web Part will verify the list permissions when users access by using the web.CurrentUser.

DoesUserHavePermissions method.
You need to ensure that when users do not have permissions to the list; the Web Part displays the company's

logo.

Which code segment should you add to the Web Part?

A. RunWithElevatedPrivileges
B. web.AllowUnsafeUpdates= true
C. web.CurrentUser.RequireRequestToken = false
D. web.ValidateFormDigest()
Definition
A
Term
QUESTION 18

You create a Web Part that contains the following code segment. (Line numbers are included for reference
only.)
01 Public Class WebPart1
02 Inherits WebPart
03
04 Public Sub New()
05 MyBase.New
06
07 End Sub
08
09 Protected Overrides Sub CreateChildControls()
10 Dim clickButton As Button = New Button
11
12 MyBase.CreateChildControls
13 End Sub


15 Protected Overrides Sub RenderContents(ByVal writer As HtmlTextWriter)
16
17 MyBase.RenderContents(writer)
18 End Sub
19 End Class
You discover that the clickButton button does not appear.
You need to ensure that clickButton appears.
What should you do?



A. Delete line 12.
B. Move line 10 to line 16.
C. Add the following line of code at line 11.
Controls.Add(clickButton)
D. Add the following line of code at line 11.
clickButton.Page = me.Page
Definition
C
Term
QUESTION 19

You plan to create two Web Parts named Products and ProductDetails. You create an interface that contains
the following code segment.
Public
Interface Interface1

Property Productid As String
End Interface
You need to ensure that the Products Web Part sends Productid to the ProductDetails Web Part. You must
achieve this goal by using the ASP.NET Web Part connection framework.
What should you do?

A. Implement Interface1 in the Products Web Part.
B. Implement Interface1 in the ProductDetails Web Part.
C. Add a private set-accessor-declaration to the Productid property.
D. Add a protected set-accessor-declaration to the Productid property.
Definition
A
Term
QUESTION 20

You plan to create one provider Web Part and two consumer Web Parts. You need to ensure that the
consumer Web Parts can receive data from the provider Web Part. You create an interface that contains the
following code segment.
Public

Interface Interface1

Property Parameter1 As String
End Interface
What should you do next?

A. Implement Interface1 in the provider Web Part.

B. Implement IWebPartField in the provider Web Part.
C. Create a set accessor for Parameter1.
D. Create a second interface and use it to communicate with the provider Web Part.
Definition
D
Term
QUESTION 21

You create a Web Part named WP1.
You need to ensure that the name of the Web Part displays as Corporate in SharePoint.
What should you do?


A. Rename WP1.webpart as Corporate.webpart.
B. In WP1.webpart, change the Title property to Corporate.
C. In the constructor of WP1.cs, add the following line of code.
Page.Title="Corporate"
D. In the Elements.xml file, change the Name property of the element to Corporate.
Definition
B
Term
QUESTION 22

You create a Web Part that contains the following logging code. (Line numbers are included for reference
only.)
01Try
02 ...
03Catch ex As Exception
05System.Diagnostics.EventLog.WriteEntry("WebPart Name", ("Exception Information: " + ex.Message),
EventLogEntryType.Error) 06End Try
You discover that line 05 causes an error.
You need to resolve the error.
What should you do?


A. Run the code segment at line 05 inside a RunWithElevatedPrivileges delegate.
B. Add the following code at line 04.
If web.CurrentUser.IsSiteAuditor = False Then
System.Diagnostics.EventLog.WriteEntry("WebPart Name",
"Exception Information: " & ex.Message, EventLogEntryType.[Error]) End If
C. Add the following code at line 04
If web.CurrentUser.IsSiteAdmin = False Then
System.Diagnostics.EventLog.WriteEntry("WebPart Name",
"Exception Information: " & ex.Message, EventLogEntryType.[Error]) End If
D. Change line 05 to the following code segment.
System.Diagnostics.EventLog.WriteEntry("WebPart Name",
"Exception Information", EventLogEntryType.Error)
Definition
A
Term
QUESTION 23

You create a Web Part that calls a function named long Call. You discover that long Call takes a long time to
execute. You need to display in the Developer Dashboard how long it takes to execute long Call.
Which code segment should you use?



A. Dim startTime As DateTime = DateTime.Now
longCall()
Trace.Write("Long Call " & DateTime.Now.Subtract(startTime).Seconds)
B. Dim startTime As DateTime = DateTime.Now
longCall()
Trace.TraceWarning("Long Call " & DateTime.Now.Subtract(startTime).Seconds)
C. Monitor.Enter("Long Call")
If True Then
longCall()
End If
Monitor.[Exit]("Long Call")
D. Using monitoredScope As New SPMonitoredScope("Long Call") longCall()
End Using
Definition
D
Term
QUESTION 24

You plan to activate the Developer Dashboard.
You create a command line application that contains the following code segment. (Line numbers are included
for reference only.)
01Dim cs As SPWebService = SPWebService.ContentService
02cs.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.[On] You execute the
application and discover that the Developer Dashboard fails to appear. You need to ensure that the
application activates the Developer Dashboard.
What should you do?


A. Add the following line of code at line 03.
cs.Update()
B. Add the following line of code at line 03.
cs.DeveloperDashboardSettings.Update()
C. Change line 02 to the following code segment.
cs.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.Off
D. Change line 02 to the following code segment.
cs.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.OnDemand
Definition
B
Term
QUESTION 25

You have the following event receiver. (Line numbers are included for reference only.) 01Public Overloads
Overrides Sub FieldDeleting
(ByVal properties As SPListEventProperties)
02 MyBase.FieldDeleting(properties)
03 If properties.FieldName = "Status" Then
06 End If
07End Sub
You need to cancel the operation and redirect the user to a custom error page if the name of the deleted field
is Status.
Which code segments should you add at lines 04 and 05?

A. 04properties.ReceiverData = "/_layouts/customErrorPage.aspx" 05properties.Cancel = True
B. 04properties.RedirectUrl = "/_layouts/customErrorPage.aspx" 05properties.Cancel = True '

C. 04properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl 05properties.ReceiverData = "/
_layouts/customErrorPage.aspx"
D. 04properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl 05properties.RedirectUrl = "/
_layouts/customErrorPage.aspx"
Definition
D
Term
QUESTION 26

You are creating an event receiver. The event receiver will have a field named Title and a field named
Priority.
You write the following code segment for the event receiver. (Line numbers are included for reference only.)
01Public Overloads Overrides Sub ItemUpdating(ByVal prop As SPItemEventProperties) 02MyBase.
ItemUpdating(prop)
06End Sub
You need to ensure that when the Title field is changed to include the word IMPORTANT, the Priority field is
set to URGENT.
Which code segments should you add at lines 03, 04 and 05?


A. 03If prop.AfterProperties("vti_title").ToString().Contains("IMPORTANT") Then 04prop.AfterProperties
("Priority") = "URGENT"
05End If
B. 03If prop.AfterProperties("vti_title").ToString().Contains("IMPORTANT") Then 04prop.ListItem("Priority") =
"URGENT"
05End If
C. 03If prop.BeforeProperties("vti_title").ToString().Contains("IMPORTANT") Then 04prop.AfterProperties
("Priority") = "URGENT"
05End If
D. 03If prop.ListItem("Title").ToString().Contains("IMPORTANT") Then 04prop.AfterProperties("Priority") =
"URGENT"
05End If
Definition
A
Term
QUESTION 28

You have a timer job that has the following constructors. (Line numbers are included for reference only.)


01public TimerJob1 () : base() { }
02public TimerJob1(SPWebApplication wApp)
You need to ensure that the timer job runs on the first available timer server only.
Which base class constructor should you use at line 02?


A. public TimerJob1(SPWebApplication wApp) : base
(null, wApp, null, SPJobLockType.ContentDatabase) { }
B. public TimerJob1(SPWebApplication wApp): base
(null, wApp, null, SPJobLockType.Job){ }
C. public TimerJob1(SPWebApplication wApp):base
(null, wApp, null, SPJobLockType.None){}
D. public TimerJob1(SPWebApplication wApp):base
("TimerJob1", wApp, null, SPJobLockType.None){}
Definition
B
Term
QUESTION 29

You create a client application that remotely calls the Business Connectivity Services (BCS) object model.
You need to create the context that will be used to request a cache refresh.
Which code segment should you use?


A. Dim cCtx As BdcService = SPFarm.Local.Services.GetValue(Of BdcService)(String.Empty)
B. Dim cCtx As New ClientContext(String.Empty)
C. Dim cCtx As New RemoteOfflineRuntime()
D. Dim cCtx As New RemoteSharedFileBackedMetadataCatalog()
Definition
C
Term
QUESTION 30

You need to programmatically add a user named User1 to a group named Group1.
You write the following code segment. (Line numbers are included for reference only.)
01Dim login As String = "User1"
02Dim grpName As String = "Group1"
03Dim user As SPUser = SPContext.Current.Web.EnsureUser(login)
04Dim group As SPGroup = SPContext.Current.Web.Groups(grpName)
05
06group.Update()
Which code segment should you add at line 05?


A. group.AddUser(user)
B. group.Owner = user
C. user.AllowBrowseUserInfo = True
D. user.Update()
Definition
A
Term
QUESTION 31

You need to create a Web Part that creates a copy of the out-of-the box Contribute permission level. Which
code segment should you implement in the Web Part?


A. Dim myRole As New SPRoleDefinition()
myRole.Name = "Contribute"
SPContext.Current.Web.RoleDefinitions.Add(myRole)
B. Dim myRole As New SPRoleDefinition(SPContext.Current.Web.RoleDefinitions("Contribute"))
myRole.Name = "MyContribute"
SPContext.Current.Web.RoleDefinitions.Add(myRole)
C. Dim myRole As New SPRoleDefinition(SPContext.Current.Web.RoleDefinitions("MyContribute"))
myRole.Description = "Contribute"
SPContext.Current.Web.RoleDefinitions.Add(myRole)
D. Dim myRole As New SPRoleDefinition(SPContext.Current.Web.RoleDefinitions("MyContribute"))
myRole.Name = "Contribute"
SPContext.Current.Web.RoleDefinitions.Add(myRole)
Definition
B
Term
QUESTION 32

You need to create a Web Part that verifies whether a user who accesses the Web Part page is a member of
a group named Group1.
Which code condition should you use?


A. SPContext.Current.Web.Groups("Group1").ContainsCurrentUser
B. SPContext.Current.Web.SiteUsers
(SPContext.Current.Web.CurrentUser.ID).Groups("Group1") <> null
C. SPContext.Current.Web.SiteUsers
(SPContext.Current.Web.CurrentUser.ID).Groups("Group1") = null
D. SPContext.Current.Web.Users("Group1").IsDomainGroup
Definition
A
Term
QUESTION 33

You have a SharePoint list named Assets that contains 1,000,000 items. The list contains a column named
Urgent. Approximately 100 items have a value of True in their Urgent column. You use the following line of
code to retrieve the Assets list.
Dim assetsList As SPList = currentWeb.Lists("assets")
You need to retrieve all of the items in the list that have a value of True in their Urgent column. You must
retrieve the items in the minimum amount of time.
What should you do?


A. Iterate through the assetsList.Items collection.
B. Iterate through the assetsList.Fields collection.
C. Call assetsLists.GetItems and specify the SPQuery parameter.
D. Call assetsList.Items.GetDataTable() and retrieve DataRowCollection.
Definition
C
Term
QUESTION 34

You create a Web Part.
The Web Part contains a grid view named GridView1 and the following code segment. (Line numbers are
included for reference only.)
01Dim dc As New IntranetDataContext("http://intranet")
02MyGridView.DataSource = From announce In dc.Announcements _



04Select announce
IntranetDataContext is a LINQ context.
You need to ensure that GridView1 only displays items from Announcements that have an expiry date that is
greater than or equal to the current date.
What should you do?


A. Change line 04 to the following code segment.
Select Not announce.Expires.HasValue
B. Change line 04 to the following code segment.
Select announce.Expires.Value.CompareTo(DateTime.Now) >= 0
C. Add the following line of code at line 03.
Where announce.Expires.Value.CompareTo(DateTime.Now) >= 0 _
D. Add the following line of code at line 03.
Order By announce.Expires.Value.CompareTo(DateTime.Now) >= 0 _
Definition
C
Term
QUESTION 35

You create a Microsoft .NET Framework console application that uses a Representational State Transfer
(REST) API to query a custom list named Products.
The application contains the following code segment.
Dim codc As New AdventureWorksDataContext(New Uri("http://contoso/_vti_bin/listdata.svc"))
codc.Credentials = CredentialCache.DefaultCredentials
You need to read all items in Products into an object.
Which method should you use?


A. codc.Products.All
B. codc.Products.AsQueryable
C. codc.Products.ElementAt
D. codc.Products.ToList
Definition
D
Term
QUESTION 36

You have a SharePoint Web application that has the URL http://intranet. You are creating a Microsoft .NET
Framework application that will display the title of the SharePoint Web application and will execute outside of
the SharePoint server.
You create a textbox named textBoxTitle.
You write the following code segment. (Line numbers are included for reference only.)
01Dim context As New ClientContext("http://intranet")
02
03Dim site As Web = context.Web
04context.Load(site)
05
06textBoxTitle.Text = site.Title
You discover that line 04 generates an error.
You need to ensure that the .NET application displays the title of the SharePoint Web application in
textBoxTitle.
What should you do?


A. Add the following line of code at line 02.
context.ExecuteQuery()

B. Add the following line of code at line 02.
context.ValidateOnClient = true
C. Add the following line of code at line 05.
context.ExecuteQuery()
D. Add the following line of code at line 05.
context.ValidateOnClient = true
Definition
C
Term
QUESTION 37

You have a SharePoint site collection that has the URL http://contoso/sites/finance. You are creating a
Microsoft .NET Framework console application that will use the SharePoint client object model to create a site
in the site collection.
The application contains the following code segment. (Line numbers are included for reference only.) 01Dim
cCtx As New ClientContext("http://contoso/sites/finance") 02Dim root As Web = cCtx.Site.RootWeb
03cCtx.Load(root)
04Dim webInfo As New WebCreationInformation()
05webInfo.Title = "site1"
06webInfo.Url = "site1"
07webInfo.WebTemplate = "MPS#2"
08root.Webs.Add(webInfo)
10cCtx.Dispose()
You need to ensure that the application creates the site.
Which code segment should you add at line 09?


A. cCtx.ExecuteQuery()
B. cCtx.Site.RootWeb.Update()
C. root.Context.Dispose()
D. root.Update()
Definition
A
Term
QUESTION 38

You have a Microsoft .NET Framework console application that uses the SharePoint client object model. The
application contains the following code segment. (Line numbers are included for reference only.) 01 Dim cCtx
As ClientContext = New ClientContext("http://contoso/sites/finance") 02 Dim root As Web = cCtx.Site.
RootWeb
03 cCtx.Load(root)
04 Dim webInfo As WebCreationInformation = New WebCreationInformation 05 webInfo.Title = "site1"
06 webInfo.Url = "site1"
07 webInfo.WebTemplate = "MPS#2"
08 root.Webs.Add(webInfo)
10 cCtx.Dispose
You need to ensure that the application queries Shared Documents for a document named Doc1.docx.
Which code element should you add at line 09?


A.
B.
C.
D.
Definition
B
Term
QUESTION 39

You have a document library named MyDocs. MyDocs has a column named Column1. Column1 is a required
column.
You discover that many documents are checked out because users fail to enter a value for Column1.
You need to create a Web Part to delete the documents.
Which code segment should you include in the Web Part?


A. For Each file As SPCheckedOutFile In
CType(SPContext.Current.Web.Lists("MyDocs"),SPDocumentLibrary).CheckedOutFiles file.Delete
Next
B. For Each file As SPItem In SPContext.Current.Web.Lists("MyDocs").Items If (file("CheckOutStatus") =
"CheckOut") Then
file.Delete
End If
Next
C. For Each file As SPListItem In CType(SPContext.Current.Web.Lists("MyDocs"),SPDocumentLibrary).
Items If (file("CheckOutStatus") = "CheckOut") Then
file.Delete
End If
Next
D. For Each file As SPCheckedOutFile In
CType(SPContext.Current.Web.Lists("MyDocs"),SPDocumentLibrary).CheckedOutFiles file.
TakeOverCheckOut
Next
Definition
A
Term
QUESTION 40

You have a document library named Documents. Minor and major version management is enabled for the
document library.
You plan to add a document named MyFile.docx to Documents. You create a console application that
contains the following code segment. (Line numbers are included for reference only.)
01Using site As New SPSite("http://intranet")
02 Dim documents As SPList = site.RootWeb.Lists("Documents")
03 Dim fstream As FileStream = File.OpenRead("MyFile.docx")
04 Dim content As Byte() = New Byte(fstream.Length - 1) {}
05 fstream.Read(content, 0, CInt(fstream.Length))
06 fstream.Close()
07 site.RootWeb.Files.Add(documents.RootFolder.Url & "/MyFile.docx", content, True)
08 Dim file As SPFile = site.RootWeb.GetFile(documents.RootFolder.Url & "/ MyFile.docx")
09 file.CheckIn(String.Empty)
10
11End Using
You need to ensure that all users can see the document.
Which code segment should you add at line 10?


A. file.CanOpenFile(true)
B. file.Publish(string.Empty)
C. file.ReleaseLock(string.Empty)
D. file.Update()
Definition
B
Term
QUESTION 41

You have a custom user profile property named MyProperty. You need to create a Web Part that displays the
value of MyProperty for the current user.
Which code segment should you use?


A. Dim profile As String = SPContext.Current.Web.Properties("CurrentUser/MyProperty")
B. Dim profile As String = SPContext.Current.Web.Users("MyProperty").ToString()
C. Dim profileManager As New UserProfileManager(SPServiceContext.Current) Dim userProfile As
UserProfile = profileManager.GetUserProfile (SPContext.Current.Web.CurrentUser.LoginName)
Dim profile As String = userProfile("MyProperty").ToString()
D. Dim profileManager As New UserProfileManager(SPServiceContext.Current) Dim userProfile As
UserProfile = profileManager.GetUserProfile (SPContext.Current.Web.CurrentUser.LoginName)
Dim profile As String = userProfile.Properties.GetPropertyByName ("MyProperty").ToString()
Definition
C
Term
QUESTION 42

You need to create a Web Part that adds a term set to the current SharePoint site collection's term store. You
write the following code segment. (Line numbers are included for reference only.) 01Dim
txtBoxTermSetToAdd As New System.Web.UI.WebControls.TextBox() 02Dim session As New
TaxonomySession(SPContext.Current.Site) 03Dim addedTerm As TermSet = session.TermStores(0).Groups
("MyNewTermStore").CreateTermSet(txtBoxTermSetToAdd.Text) Which code segment should you add at line
04?

A. addedTerm.Export()
B. addedTerm.TermStore.CommitAll()
C. SPContext.Current.Site.WebApplication.Update()
D. SPContext.Current.Web.AllowUnsafeUpdates = True
Definition
B
Term
QUESTION 43

You need to create a Web Part that displays all social tags entered by users.
Which code segment should you use?

A. Dim session As New TaxonomySession(SPContext.Current.Site)
Dim socialTags As TermSet = session.DefaultKeywordsTermStore.SystemGroup.TermSets("Keywords")
B. Dim session As New TaxonomySession(SPContext.Current.Site)
Dim socialTags As TermSet = session.DefaultKeywordsTermStore.SystemGroup.TermSets("Keywords")
C. Dim socialTags As TermSet = DirectCast(SPContext.Current.Site.WebApplication.Properties("Tags"),
TermSet)
D. Dim socialTags As TermSet = DirectCast(SPContext.Current.Web.AllProperties("Keywords"), TermSet)
Definition
A
Term
QUESTION 44

You need to create a custom application that provides users with the ability to create a managed property.
The managed property name must be specified in the args[1] parameter.
You write the following code segment for the application. (Line numbers are included for reference only.)



01Dim currentSite As New SPSite("http://intranet")
02Dim context As SearchContext = SearchContext.GetContext(currentSite)
03Dim schema As New Schema(context)
Which code segment should you add to the application?


A. context.SearchApplication.CrawlStores.Create(args(1))
B. Dim properties As ManagedPropertyCollection = schema.AllManagedProperties
Dim newMng As ManagedProperty = properties.Create(args(1), ManagedDataType.Text)
C. Dim properties As ManagedPropertyCollection = schema.AllManagedProperties
Dim newMng As ManagedProperty = properties.CreateCrawlMonProperty() newMng.Name = args(1)
D. schema.AllCategories.Create(args(1), Guid.NewGuid())
Definition
B
Term
QUESTION 45

You need to create a Web Part that displays all of the content created by a specific user. You write the
following code segment. (Line numbers are included for reference only.) 01Dim kRequest As New
KeywordQuery(ServerContext.Current) 03kRequest.QueryText = strQuery
04Dim resultTbls As ResultTableCollection = kRequest.Execute() Which code segment should you add at line
02?

A. Dim strQuery As String = "author:" & searchAuthor
B. Dim strQuery As String = "docID:" & searchAuthor
C. Dim strQuery As String = "SELECT Title, Rank, Write, Url FROM SCOPE() WHERE author = " &
searchAuthor
D. Dim strQuery As String = "SELECT Title, Rank, Write, Url FROM SCOPE() WHERE docID = " &
searchAuthor
Definition
A
Term
QUESTION 46

You need to create a Web Part that displays all of the content created by a specific user.
You write the following code segment. (Line numbers are included for reference only.)
01Dim qry As New FullTextSqlQuery(ServerContext.GetContext(SPContext.Current.Site))
02qry.ResultTypes = ResultType.RelevantResults
03
04qry.QueryText = strQuery
05Dim results As ResultTableCollection = qry.Execute()
Which code segment should you add at line 03?


A. Dim strQuery As String = "author:" & searchAuthor
B. Dim strQuery As String = "docID:" & searchAuthor
C. Dim strQuery As String = "SELECT Title,Author,Path
FROM SCOPE() WHERE author = '" & searchAuthor & "'"
D. Dim strQuery As String = "SELECT Title,Creator,Path
FROM SCOPE() WHERE docID = '" & searchAuthor & "'"
Definition
C
Term
QUESTION 47

You have a list named Projects that contains a column named ClassificationMetadata.


You need to create a Web Part that updates the ClassificationMetadata value to NA for each item in the
Projects list.
You write the following code segment. (Line numbers are included for reference only.)
01For Each currentItem As SPListItem In SPContext.Current.Web.Lists("Projects").Items


03Next
Which code segment should you add at line 02?


A. currentItem("ClassificationMetadata") = "NA"
B. currentItem.Fields("ClassificationMetadata").DefaultFormula = "NA"
C. currentItem.Fields("ClassificationMetadata").DefaultValue = "NA"
D. currentItem("Value") = "ClassificationMetadata/NA"
Definition
A
Term
QUESTION 48

You create a Web Part that queries a list.
The Web Part contains the following code segment. (Line numbers are included for reference only.)
01Protected Overloads Overrides Sub Render(ByVal writer As HtmlTextWriter) 02 Dim spInToken As
SPUserToken = GetTheContext(SPContext.Current.Site) 03 Using aSite As New SPSite(curSiteCtx.ID,
spInToken)
04 ...
05 End Using
06 End Sub
07Private Function GetTheContext(ByVal nWeb As SPSite) As SPUserToken 08 nWeb.
CatchAccessDeniedException = False
09 Dim spToken As SPUserToken = Nothing
10 Try
11 spToken = nWeb.SystemAccount.UserToken
12 Catch generatedExceptionName As UnauthorizedAccessException 14 End Try
15 Return spToken
16End Function
You need to ensure that users without permissions to the list can view the contents of the list from the Web
Part.
Which code segment should you add at line 13?

A. SPSecurity.RunWithElevatedPrivileges(EvelvatedSub)
Private Sub ElevatedSub()
Using eSite As New SPSite(nWeb.ID)
spToken = nWeb.SystemAccount.UserToken
End Using
End Sub
B. SPSecurity.RunWithElevatedPrivileges(EvelvatedSub)
Private Sub ElevatedSub()
Using eSite As New SPSite(nWeb.ID)
spToken = SPContext.Current.Web.CurrentUser.UserToken
End Using
End Sub
C. spToken = nWeb.RootWeb.AllUsers(SPContext.Current.Web.Name).UserToken
D. spToken = nWeb.RootWeb.AllUsers(SPContext.Current.Web.Name).UserToken
Definition
A
Term
QUESTION 49

You create a Web Part that programmatically updates the description of the current SharePoint site. The Web
Part contains the following code segment. (Line numbers are included for reference only.)
01RunWithElevatedPrivileges(EvelateSub)
02Private Sub ElevatedSub()
03 Dim currSite As SPSite = SPContext.Current.Site
04 Dim currWeb As SPWeb = SPContext.Current.Web
05 Using eSite As New SPSite(currSite.ID)
06 Using eWeb As SPWeb = eSite.OpenWeb(currWeb.ID)
07 eWeb.AllowUnsafeUpdates = True
08 currWeb.Description = "Test"
09 currWeb.Update()
10 eWeb.AllowUnsafeUpdates = False
11 End Using
12 End Using
Users report that they receive an Access Denied error message when they use the Web Part. You need to
ensure that all users can use the Web Part to update the description of the current site.
What should you do?


A. Remove lines 07 and 10.
B. Remove lines 08 and 09.
C. Change lines 08 and 09 to use the eWeb variable.
D. Change lines 07 and 10 to use the currWeb variable.
Definition
C
Term
QUESTION 50

You create a Web Part.
You need to display the number of visits to a SharePoint site collection in a label named LblVisits. You write
the following code segment. (Line numbers are included for reference only.) 01RunWithElevatedPrivileges
(ElevateSub)
02Private Sub ElevatedSub()
03 Try
05 LblVisits.Text = site.Usage.Visits.ToString()
06 Finally
07 ...
08 End Try
09End Sub
Which code segment should you add at line 04?



A. Dim esite As New SPSite(SPContext.Current.Site.ID)
B. Dim esite As SPSite = SPContext.Current.Site
C. Dim esite As SPSite = SPContext.GetContext(HttpContext.Current).Site
D. Dim esite As SPSite = SPControl.GetContextSite(HttpContext.Current)
Definition
A
Term
QUESTION 27

You have a SharePoint list named Announcements.
You have an event receiver that contains the following code segment. (Line numbers are included for
reference only.)
01Public Overloads Overrides Sub ItemAdding(ByVal properties As SPItemEventProperties) 02If properties.
ListItem("Title").ToString().Contains("secret") Then 04End If
05End Sub
You need to prevent users from adding items that contain the word "secret" in the title to the list.
Which code segment should you add at line 03?


A. properties.Cancel = false
B. properties.Cancel = true
C. properties.Status = SPEventReceiverStatus.Continue
D. Exit Sub
Definition
B
Supporting users have an ad free experience!