Exam 70-540
-
Upload
javi-martin -
Category
Documents
-
view
233 -
download
0
Transcript of Exam 70-540
-
8/22/2019 Exam 70-540
1/100
Exam Code: 70-540
Microsoft Windows Mobile Application
Development
Question: 1
You arecreating a Microsoft Windows Mobilebased application. The application storesreal-time
order information for smalbusinesses. The numberofordersranges froma minimum of 0to a
maximum of 5000.
You need to ensure that the application achievesoptimumperformance for any number oforders
within the specified range.
Which class should you choose?
A. OrderedDictionary
B. HybridDictionary
C.ListDictionary
D.Hashtable
Question: 2
You arecreating a Microsoft Windows Mobilebased application. You are required tocreate
customdata types that derivefrom a system type.
The system typemust satisfy the folowingrequirements:
Ensure the type safety of colectionsduring compilation.
Improvethe code readability of the application.
Minimize thepotential forrun-time erors.
You need to identify the system typethat meets theoutlinedrequirements.
Which systemtype should you choose?
A. Delegate type
-
8/22/2019 Exam 70-540
2/100
B. Nulable type
C. Generic type
D.Value type
Question: 3
You arecreating a Microsoft Windows Mobilebased application. The application usesa custom
exception class named MyException that transmitsstack information. The MyException class is
derived from the Exceptionclass.Theapplication contains amethod named ThrowException.
You write the folowing code segment.
try{ThrowException();}
The ThrowException method throws an exceptionoftype MyException.
You need to rethrowthe exception.You also need to preserve thestack information of previous
exceptions.
Which code segment should you use?
A. catch( MyExceptionex) {
throw new Exception( ex.Message );
}
B. finaly {
throw new MyException();
}
C.catch {
throw;
}
D.catch (Exception ex) {
throw ex;
-
8/22/2019 Exam 70-540
3/100
}
Question: 4
You arecreating a Microsoft Windows Mobilebased application. You create a class named
InventoryManager. The InventoryManager classuses eventsto alert subscribers aboutchanges
in inventorylevels.
You need to create delegates in the InventoryManager class to raise eventstosubscribers.
Which code segment should you use?
A. public event InventoryChangeEventHandlerOnInventoryChange;
public delegate voidInventoryChangeEventHandler
(object source, EventArgs e);
B. private event InventoryChangeEventHandler OnInventoryChange;
privatedelegate voidInventoryChangeEventHandler
(object source, EventArgs e);
C.public eventEventHandler OnInventoryChange;
publicvoidInventoryChangeHandler(object source, EventArgs e) {
this.OnInventoryChange();
}
D.private eventEventHandler OnInventoryChange;
privatevoidInventoryChangeHandler(object source, EventArgs e) {
this.OnInventoryChange();
}
Question: 5
You arecreating a Microsoft Windows Mobilebased inventory application.
The application mustcreate reports that display inventory partnumbers.
You need to write amethodnamed WritePart that displays the part numbers inthe folowing
format:
A minimumofthree digits to the left of the decimal point
-
8/22/2019 Exam 70-540
4/100
Exactly two digits to the right of the decimal point
Left-alignedoutput
Which code segment should you use?
A. public static void WritePart(IFormatable t, CultureInfoci)
{ Console.WriteLine
("{0,-30}{1,30}", "Part:", t.ToString("000.00",ci);
}
B. public static void WritePart(IFormatable t, CultureInfoci)
{ Console.WriteLine
("{0,-30}{1,30}", "Part:", t.ToString("000.##",ci);
}
C.public static voidWritePart(IFormatable t,CultureInfo ci)
{ Console.WriteLine
("{0,30}{1,30}", "Part:",t.ToString("###.##",ci);
}
D.public static voidWritePart(IFormatable t,CultureInfo ci){
Console.WriteLine
("{0,30}{1,30}", "Part:",t.ToString("###.00",ci);
}
Question: 6
You arecreating a Microsoft .NET Compact Framework application.Theapplication uses a
StringBuilder class to manipulate text.
You write the folowing code segment.
StringBuilder sb =newStringBuilder(100);
-
8/22/2019 Exam 70-540
5/100
Afterthe codesegment is executed, the text bufer of theStringBuilder class displays the
folowing text:
Microsoft Corporation, Redmond,WA.
You need to write acode segment to clearthe text of the StringBuilder class.
Which code segment should you use?
A. sb.Capacity = 0;
B. sb.Length= 0;
C.sb.Replace(sb.ToString(), ",0,100);
D.sb.Remove(0, 100);
Question: 7
You arecreating a Microsoft Windows Mobilebased application. The application wil manage
product inventory forretail stores. You arecreating a classthat wil contain a method named
Contains.Themethod wil search forthe items in the store. The itemsareof reference types and
value types.
You need to identify thecode that uses the minimum amount of execution timefor both reference
types and value types.
Which code segment should you use?
A. public boolContains(T[]aray, T value) {
for (int i = 0;i< aray.Length; i++) {
if (EqualityComparer.Default.Equals(aray[i], value)
returntrue;
}
returnfalse;
}
B. public boolContains(T[]aray, object value) {
-
8/22/2019 Exam 70-540
6/100
for (int i = 0; i < aray.Length; i++)
{ if
(aray.GetValue(i).Equals(value)
returntrue;
}
returnfalse;
}
C.public bool Contains(IEnumerable aray, object value) {
foreach (objectobj in aray) {
if (obj.Equals(value)
returntrue;
}
returnfalse;
}
D.public bool Contains(IEnumerable aray, object value) {
foreach (objectobj in aray) {
if (obj == value)
returntrue;
}
returnfalse;
}
Question: 8
You arecreating a Microsoft Windows Mobilebased application. You create a class named
Employee. You alsocreate an Executive class, aManagerclass, and aProgrammer class. These
three classes inherit from theEmployee class.
You need to create a custom type-safe colection that managesonlythose classes that are
-
8/22/2019 Exam 70-540
7/100
derived from the Employee class.
Which code segment should you choose?
A. classEmployeeColection< T > : List< T >
B. classEmp l oyeeColection < T> : IColection
C.class EmployeeColection :ColectionBase where T:class
D.class EmployeeColection :ColectionBase where T:Employee
Question: 9
You arecreating a multithreaded MicrosoftWindows Mobilebased application.
The application has two separate procedures.Each procedure must runon its own threads.
publicvoidThreadProc1() { }
publicvoidThreadProc2() { }
ThreadProc1 mustcomplete execution beforeThreadProc2 begins execution.
You need to write the code segment torun both procedures.
Which code segment should you use?
A. Thread thread1 = new Thread(new ThreadStart(ThreadProc1);
Thread thread2 = new Thread(new ThreadStart(ThreadProc2);
thread1.Start();
.
thread1.Join();
thread2.Start();
B. Threadthread1 = new Thread(new ThreadStart(ThreadProc1);
Thread thread2= new Thread(new ThreadStart(ThreadProc2);
lock(thread1){
-
8/22/2019 Exam 70-540
8/100
thread1.Start();
.
}
thread2.Start();
C.Thread thread1= new Thread(new ThreadStart(ThreadProc1);
Thread thread2= new Thread(new ThreadStart(ThreadProc2);
thread1.Start();
.
Monitor.TryEnter(thread1);
thread2.Start();
Monitor.Exit(thread1);ResetInstructions Calculator
D. .Thread thread1 = new Thread(new ThreadStart(ThreadProc1);
Thread thread2 = new Thread(new ThreadStart(ThreadProc2);
thread1.Start();
.
Interlocked.Exchange(refthread1, thread2);
thread2.Start();
Question: 10
You arecreating a Microsoft .NET Compact Framework application.
You write the folowing code segment.
publicclass Target{
publicvoidSetValue(int value) { }
}
-
8/22/2019 Exam 70-540
9/100
You need to write amethodnamed CalSetValue that calsthe SetValuemethodby usinglate
binding.
Which code segment should you use?
A. public void CalSetValue(int value) {
Target target = new Target();
MethodInfomi = target.GetType().GetMethod("SetValue");
mi.Invoke(target, new object[] { value });
}
B. public void CalSetValue(int value)
{ Target target = new Target();
MethodInfomi = target.GetType().GetMethod("Target.SetValue");
mi.Invoke(target, new object[] { value });
}
C.public void CalSetValue(int value)
{ Target target = new Target();
MethodInfomi = target.GetType().GetMethod("Target.SetValue");
mi.Invoke(value, nul);
}
D.public void CalSetValue(int value)
{ Target target = new Target();
MethodInfomi = target.GetType().GetMethod("SetValue");
mi.Invoke(value, nul);
}
Question: 11
You arecreating a Microsoft Windows Mobilebased application. The application contains a
Windows Form thathas a panel.
-
8/22/2019 Exam 70-540
10/100
You need to ensure that the panel remains atachedtothe botomofthe WindowsFormeven
when the screen size changes. Atrun timethe usermust be able toresize thepanel by usinga
spliter control.
What should you do?
A. Set theDock property of the panel equaltoDockStyle.Botom.
B. Set the Anchor property of the panel equaltoAnchorStyles.Botom.
C.Set the Heightproperty of the panel equal tothe Height property of the Windows Form.
D.Set the Control.Size propertyofthe panelequal to theControl.Size property of the Windows
Form.
Question: 12
You arecreating a Microsoft Windows Mobilebased application. The application contains a
Windows Form thathas a textboxcontrol namedTxtSalary. Theapplication also contains a class
named Employee that hasa property namedSalary.
You create aninstanceof the Employeeclass namedempin the Windows Form.
You need to write the code segment that bindsTxtSalarytoemp.You also need to ensurethat
the code segment displaysthe salary of an employee as acurencyvalue prefixedby the
curencysymbol.
Which code segment should you use?
A. Binding bind = new Binding("Text", emp, "Salary");
bind.FormatingEnabled= true;
bind.FormatString = "C";
TxtSalary.DataBindings.Add(bind);
B. Binding bind = new Binding("Text", emp, "Salary");
bind.FormatingEnabled= true;
-
8/22/2019 Exam 70-540
11/100
bind.FormatInfo= new NumberFormatInfo();
TxtSalary.DataBindings.Add(bind);
C.Bindingbind = new Binding("Salary",emp,"Curency");
bind.FormatingEnabled= true;
bind.FormatInfo= new NumberFormatInfo();
TxtSalary.DataBindings.Add(bind);
D.Bindingbind = new Binding("Salary", emp,"C");
bind.FormatingEnabled= true;
TxtSalary.DataBindings.Add(bind);
Question: 13
You arecreating a Microsoft Windows Mobilebased application. The WindowsMobilebased
application contains aWindowsForm that has two text boxes.
You create KeyPressEventHandler delegates for the Windows Form and thetwo text boxes to
handle the KeyPress events.The KeyPressEventHandler delegate for the Windows Form
ensures thatonlyletersor digits areentered. The KeyPressEventHandler delegate forthe text
boxes contains codethat validates the leters or digits that are entered.
You need to ensurethat the KeyPress events are handled appropriately.
Which twotasksshould you perform?(Each corectanswerpresentspartofthe solution. Choose
two.)
A.Set the KeyPreview property of the Windows Form to True.B.
Set theKeyPreview property ofthe WindowsFormto False.
Page6 of58
C.Set the Handled property of the KeyEventArgs object toTrue insidethe
KeyPressEventHandler method for the Windows Form if theentered characterisneither a
leternor a digit.
D.Set the Handled property of the KeyEventArgs object toFalse insidethe
KeyPressEventHandler method for the Windows Form if theentered characterisneither a
-
8/22/2019 Exam 70-540
12/100
leternor a digit.
E. Set theHandledpropertyofthe KeyEventArgsobject to False inside the
KeyPressEventHandler method for the text boxes.
F. Set the Handled property of the KeyEventArgs object to True insidethe
KeyPressEventHandler method for the text boxes.
Question: 14
You arecreating a Microsoft Windows Mobile smartphonebasedapplication.
The application has a Windows Form.Theform has amain menucontrolnamedMnuMain.
The formmust contain two top-levelmenus named MnuOptionsand MnuHelp. The MnuOptions
menumust contain two submenus named MnuNew and MnuEdit.
The top-level menus must be activated by using the folowing soft keys:
Right soft key forthe MnuOptions menu
Left soft key for theMnuHelp menu
You write the folowing code segment.
MenuItem MnuHelp= new MenuItem();
MenuItem MnuOptions= new MenuItem();
MenuItem MnuNew = new MenuItem();
MenuItem MnuEdit = new MenuItem();
You need to ensurethat the menusmeet the outlined requirements.
Which code segment should you use?
A. MnuOptions.MenuItems.Add(MnuNew);
MnuOptions.MenuItems.Add(MnuEdit);
MnuMain.MenuItems.Add(MnuOptions);
MnuMain.MenuItems.Add(MnuHelp);
B. MnuOptions.MenuItems.Add(MnuNew);
MnuOptions.MenuItems.Add(MnuEdit);
MnuMain.MenuItems.Add(MnuHelp);
-
8/22/2019 Exam 70-540
13/100
MnuMain.MenuItems.Add(MnuOptions);
C.MnuOptions.MenuItems.Add(MnuHelp);
MnuOptions.MenuItems.Add(MnuNew);
MnuOptions.MenuItems.Add(MnuEdit);
MnuMain.MenuItems.Add(MnuOptions);Reset Instructions Calculator.
D. MnuOptions.MenuItems.Add(MnuNew);
MnuOptions.MenuItems.Add(MnuEdit);
MnuHelp.MenuItems.Add(MnuOptions);
MnuMain.MenuItems.Add(MnuHelp);
Question: 15
You arecreating a Microsoft Windows Mobilebased application. You are creating atext box
control namedDigitBoxthat alows only numbers to be entered.
The classesthat inherit from the DigitBox control mustbe able to alow characters other than
numbers to be entered.
You need to write the corect class definition for theDigitBoxcontrol.
Which code segment should you use?
A. public class DigitBox : TextBox {
protected overide void OnKeyPress(KeyPressEventArgs e) {
if (char.IsDigit(e.KeyChar) == false) e.Handled = true;
}
}
B. public class DigitBox : TextBox {
publicDigitBox() {
this.KeyPress+= new KeyPressEventHandler(DigitBox_KeyPress);
}
private voidDigitBox_KeyPress(object sender,
KeyPressEventArgs e) {
if (char.IsDigit(e.KeyChar) == false) e.Handled = true;
-
8/22/2019 Exam 70-540
14/100
}
}
C.public classDigitBox: TextBox {
protected overide void OnKeyPress(KeyPressEventArgs e) {
if (char.IsDigit(e.KeyChar) == false) e.Handled = false;
}
}
D.public classDigitBox: TextBox {
publicDigitBox() {
this.KeyPress+= new KeyPressEventHandler(DigitBox_KeyPress);
}
private voidDigitBox_KeyPress(object sender,
KeyPressEventArgs e) {
if (char.IsDigit(e.KeyChar) == false) e.Handled = false;
}
}
Question: 16
You arecreating a Microsoft Windows Mobilebased application. The application contains a
Windows Form. The formcontainsa panel thathas constituent controls.
You need to designthe panel such thatit remainsin the lower-left portionofthe form.
What should you do?
A. Setthe Anchor property of the panel toAnchorStyles.Left.
B. Set the Location property of the panel to the 0,0 position of the form.
C.Set the Anchor propertyof the panel to AnchorStyles.Left andAnchorStyles.Botom.
D.Set the Locationproperty of thepanel to a horizontalpoint at position 0and a verticalpoint to
the height ofthe form.
-
8/22/2019 Exam 70-540
15/100
Question: 17
You arecreating a Microsoft Windows Mobilebased application. The application contains a
Windows Form anda class namedCustomPanel. The form contains thefolowing objects:
Two butons named BtnNext and BtnFinish
Ten Panel objects
Two CustomPanel objects named PreviousPanel and CurentPanel
The PreviousPanel object refersto the previously displayed panel object.TheCurent Panel
object referstothe curently displayed panelobject.
The CustomPanel class contains two eventhandlermethodsnamed NextClick and FinishClick.
The application mustalow a userto navigate to the next panel object in theform when the user
clicks theBtnNext buton.
You need to write the code segment for the clickevent of theBtnNext butontomeet the folowing
requirements:
Ensure thatthe click eventofthe BtnNextbuton invokes theNextClickmethodfor the curently
displayedCustomPanel object.
Ensure thatthe click eventofthe BtnFinish butoninvokes theFinishClickmethod for al the
previouslydisplayedCustomPanel objects.
Which code segment should you use?
A. BtnNext.Click += new EventHandler(CurentPanel.NextClick);
BtnFinish.Click += new EventHandler(CurentPanel.FinishClick);
B. BtnNext.Click += new EventHandler(CurentPanel.NextClick);
BtnFinish.Click -= newEventHandler(PreviousPanel.FinishClick);
BtnFinish.Click += new EventHandler(CurentPanel.FinishClick);
C.BtnNext.Click -= new EventHandler(PreviousPanel.NextClick);
BtnNext.Click+= new EventHandler(CurentPanel.NextClick);
BtnFinish.Click += new EventHandler(CurentPanel.FinishClick);
D.BtnNext.Click -= new EventHandler(PreviousPanel.NextClick);
BtnNext.Click+= new EventHandler(CurentPanel.NextClick);
BtnFinish.Click -= newEventHandler(PreviousPanel.FinishClick);
-
8/22/2019 Exam 70-540
16/100
BtnFinish.Click += new EventHandler(CurentPanel.FinishClick);
Question: 18
You arecreating a Microsoft Windows Mobilebased application.
The application contains aWindowsForm that has the folowing code segment.(Linenumbers
are included for reference only.)
01public delegateint UiUpdateDelegate();
02private int LongRunningUiUpdate() {
03.
04}
05public voidLongRunningWork(){
06
07}
The application cals the LongRunningWork method from a diferent thread.
You need to cal the LongRunningUiUpdate methodfrom the LongRunningWork method
asynchronously.
You also need to ensure that the code segment retrieves the value returnedby the
LongRunningUiUpdatemethod.
Which code segment should you insert at line06?
A. UiUpdateDelegate del = new UiUpdateDelegate(LongRunningUiUpdate);
.
int value=(int)this.Invoke( del );
B. UiUpdateDelegate del = new UiUpdateDelegate(LongRunningUiUpdate);
IAsyncResult res= this.BeginInvoke(del);
-
8/22/2019 Exam 70-540
17/100
.
int value = (int)this.EndInvoke(res);
C.UiUpdateDelegate del =newUiUpdateDelegate(LongRunningUiUpdate);
IAsyncResult res= this.BeginInvoke(del);
.
int value= (int)res.AsyncState;
D.UiUpdateDelegate del =newUiUpdateDelegate(LongRunningUiUpdate);
IAsyncResult res= this.BeginInvoke(del);
.
this.EndInvoke(res);
int value= (int)res.AsyncState;
Question: 19
You arecreating a Microsoft Windows Mobilebased applicationthat formats XML streams.You
usethe StringWriter class to receive XMLstreams.
You need to write amethodnamed AppendNewLineToWriter that inserts new line charactersat
the end of theXML stream andreturns the resultingstring.
Which code segment should you use?
A. public string AppendNewLineToWriter(StringWriter sw ) {
string str= sw.ToString ();
returnstr.Insert ( sw.GetStringBuilder().MaxCapacity - 1, "\r\n");
}
B. public string AppendNewLineToWriter(StringWriter sw ) {
returnsw.NewLine = "\r\n";
}
C.public stringAppendNewLineToWriter(StringWriter sw )
{ StringBuilder sb = sw.GetStringBuilder ();
returnsb.Insert(sb.Capacity , "\r\n").ToString();
-
8/22/2019 Exam 70-540
18/100
}
D.public stringAppendNewLineToWriter(StringWriter sw ) {
sw.WriteLine();
returnsw.ToString ();
}
Question: 20
You create a Microsoft .NET Compact Frameworkapplication fora Microsoft Windows
Mobilebased device.
The application stores information in files that are stored in a folderon the filesystem of the
Windows Mobilebased device.
You need to enumerate thefiles andsubfolders withina specified path. Youalso need to set the
Archive atribute and the ReadOnly atribute for eachfile andsubfolder.
Which twocode segments should you use? (Each corect answer presents part of the solution.
Choose two.)
A. public void EnumerateContents(string path)
{ DirectoryInfo folder =newDirectoryInfo(path);
foreach (DirectoryInfosubFolder in
folder.GetDirectories()
{ ProcessFileorFolder(subFolder);
}
foreach (FileInfofile in folder.GetFiles()
{ ProcessFileorFolder(file);
}
}
B. public void EnumerateContents(string path)
{ DirectoryInfo folder =newDirectoryInfo(path);
-
8/22/2019 Exam 70-540
19/100
foreach (DirectoryInfosubFolder in
folder.GetDirectories(\)
{ ProcessFileorFolder(subFolder);
}
foreach (FileInfofile in folder.GetFiles()
{ ProcessFileorFolder(file);
}
}
C.public void ProcessFileorFolder(FileSystemInfoitem){
item.Atributes |=FileAtributes.Archive;
item.Atributes |=FileAtributes.ReadOnly;
}
D.Reset Instructions Calculator.public void ProcessFileorFolder(FileSystemInfoitem){
item.Atributes += FileAtributes.Archive;
item.Atributes += FileAtributes.ReadOnly;
}
Question: 21
You arecreating a Microsoft Windows Mobilebased application. The application contains a
Windows Form named Form1.
You write the folowing code segment inside theForm1 classdefinition.
publicForm1() {
InitializeComponent();
this.Load +=newEventHandler(Form1_Load);
this.Closing +=newCancelEventHandler(Form1_Closing);
}
void Form1_Load(object sender, EventArgs e)
-
8/22/2019 Exam 70-540
20/100
{ DirectoryInfo directoryInfo =
new DirectoryInfo(@"\Temp\MyApp");
directoryInfo.Create();
}
You need to delete the Temp directory when theform is closed.
Which code segment should you use?
A. void Form1_Closing(object sender,CancelEventArgse)
{ DirectoryInfo directoryInfo =new DirectoryInfo(@"\Temp");
directoryInfo.Delete(true);
}
B. void Form1_Closing(object sender,CancelEventArgse)
{ DirectoryInfo directoryInfo =new DirectoryInfo(@"\Temp");
Directory.Delete(directoryInfo.FulName);
}
C.voidForm1_Closing(object sender, CancelEventArgs e)
{ DirectoryInfo directoryInfo =new DirectoryInfo(@"\Temp");
directoryInfo.Delete(false);
}
D.voidForm1_Closing(object sender, CancelEventArgs e)
{ DirectoryInfo directoryInfo =new DirectoryInfo(@"\Temp");
directoryInfo.Delete();
}
Question: 22
You arecreating a Microsoft Windows Mobilebased application.
The application contains twoXML documents. The XML schemas forthe twodocuments are
-
8/22/2019 Exam 70-540
21/100
diferent.
You need to merge the documents intoa singleXML documentby usinga method of the
XMLDocument class.
Which method shouldyou use?
A. AppendChild
B. ImportNode
C. CreateNode
D.CloneNode
Question: 23
You arecreating anapplication for a Microsoft WindowsMobilebased device. The application
code includes aDataSetobject. The DataSet object contains twoDataTable objects named
Customer and Order.
You must retrieve themost recent copy of al Order records in theDataSetobject thatmeetthe
folowing requirements:
Order placed bythe customer thathas the CustomerID value 5.
Order changed ordeleted after thelast update in the DataSet objectissaved.
You need to write the code segment that meets theoutlined requirements.
Which code segment should you use?
A. DataRow [] modRows = orderTable.Select ("CustomerID =5",
", DataViewRowState.Deleted|
DataViewRowState.ModifiedCurent );
B. DataRow [] modRows = orderTable.Select ("CustomerID =5",
", DataViewRowState.Deleted&
DataViewRowState.ModifiedOriginal );
C.DataRow []modRows = orderTable.Select ("CustomerID= 5",
", DataViewRowState.Deleted);
-
8/22/2019 Exam 70-540
22/100
D.DataRow []modRows = orderTable.Select ("CustomerID= 5",
", DataViewRowState.Deleted|
DataViewRowState.ModifiedOriginal );
Question: 24
You arecreating a Microsoft Windows Mobilebased application.
The application wil alow userstoinput data into atext box namedtxtUserData.
You need to store the input datain a text file named Data.txtby usingthe FileStreamclass. You
also need to ensure thatthe existing data in the Data.txtfile is retained.
Which code segment should you use?
A. string path = @"\MyApp\Data.txt";
FileStream fileStream= new FileStream
(path, FileMode.CreateNew, FileAccess.Write);
Byte[] bufer = Encoding.UTF8.GetBytes(txtUserData.Text);
fileStream.Write(bufer, 0, bufer.Rank);
fileStream.Close();
B. string path = @"\MyApp\Data.txt";
FileStream fileStream= new FileStream
(path, FileMode.Create,FileAccess.Write);
Byte[] bufer = Encoding.UTF8.GetBytes(txtUserData.Text);
fileStream.Write(bufer, 0, bufer.Rank);
fileStream.Close();
C.string path =@"\MyApp\Data.txt";
FileStream fileStream= new FileStream
(path, FileMode.Append, FileAccess.Write);
Byte[] bufer = Encoding.UTF8.GetBytes(txtUserData.Text);
fileStream.Write(bufer, 0, bufer.Length);
fileStream.Close();
D.string path =@"\MyApp\Data.txt";
-
8/22/2019 Exam 70-540
23/100
FileStream fileStream= new FileStream
(path, FileMode.Truncate, FileAccess.Write);
Byte[] bufer = Encoding.UTF8.GetBytes(txtUserData.Text);
fileStream.Write(bufer, 0, bufer.Length);
fileStream.Close();
Question: 25
You arecreating a Microsoft Windows Mobilebased retail application. The applicationrelaysorder
requeststo consuming applications. Eachconsuming application uses a diferent format for
element names.
The application contains aclass named XmlTransmiter that writes theorder request to each
consuming application. The XmlTransmiterclass is derivedfrom the XmlTextWriter clas.
You need to dynamicaly change thenames of the XMLelements when order requestsare
transmited to the consuming application.
What should you do?
A. Overide theWriteStartElement methodofthe XmlTextWriter class. B.
Overide the WriteEndElement method of the XmlTextWriter class.
C.Overidethe WriteAtributesmethod of the XmlTextWriterclass.
D.Overidethe WriteQualifiedName methodofthe XmlTextWriter class.
Question: 26
You arecreating a Microsoft Windows Mobilebased application. The application stores data inan
XML text file.
You need to write amethodnamed GetFileAsStringthat wil readthe contents of the XMLtextfile
as a string.
Which code segment should you use?
A. public string GetFileAsString (string
-
8/22/2019 Exam 70-540
24/100
fileName ){ FileStream fileStream =
new FileStream ( fileName ,FileMode.Open , FileAccess.Read );
StringReader reader =newStringReader ( fileName);
returnreader.ReadToEnd ();
}
B. public string GetFileAsString (string
fileName ){ FileStream fileStream =
new FileStream ( fileName ,FileMode.Open , FileAccess.Read );
XmlTextReader reader= new XmlTextReader ( fileStream );
returnreader.Read(). ToString ();
}
C.public stringGetFileAsString (string
fileName ){ FileStream fileStream =
new FileStream ( fileName ,FileMode.Open , FileAccess.Read );
StreamReader reader =newStreamReader ( fileStream );
returnreader.ReadToEnd ();
}
D.public stringGetFileAsString (string
fileName ){ FileStream fileStream =
new FileStream ( fileName ,FileMode.Open , FileAccess.Read );
BinaryReaderreader = new BinaryReader(fileStream );
returnreader.Read(). ToString ();
}
Question: 27
You arecreating a Microsoft Windows Mobilebased application.
You write the folowing code segment.
DataSetcustomerDataSet= new DataSet("CustomerData");
-
8/22/2019 Exam 70-540
25/100
DataTableordersDataTable= new DataTable("Orders");
publicMainForm (){
InitializeComponent ();
this.ordersDataTable.Columns.Add ("OrderID", typeof(int);
this.ordersDataTable.Columns.Add ("Total", typeof(int);
customerDataSet.Tables.Add ( ordersDataTable );
}
You need to retrieverows from the Orders data tableby OrderID.
Which code segment should you use?
A. public DataRowFind( int orderID){
DataRow[] dataRows =this.ordersDataTable.Select ("OrderID = " +
orderID.ToString ();
return(dataRows.Length >0) ?dataRows [0]: nul;
}
B. public DataRowFind( int orderID){
returnthis.ordersDataTable.Rows [orderID];
}
C.public DataRow Find(int orderID ) {
returnthis.ordersDataTable.Rows.Find ( orderID );
}
D.public DataRow Find(int orderID ) {
return(DataRow)this.ordersDataTable.Compute ("select * fromOrders",
"OrderID= " + orderID.ToString();
}
Question: 28
You aremodifying an existingMicrosoft Windows Mobilebasedapplication.
The application uses a MicrosoftSQL Mobiledatabase file named Datafile.sdf.
-
8/22/2019 Exam 70-540
26/100
Usersof the Windows Mobilebased application arenot able to query the database file.
You need to verify theintegrityofthe Datafile.sdf file and repair it if itiscorupt.
Which code segment should you use?
A. SqlCeEngine engine = new SqlCeEngine("Data Source =
'Datafile.sdf'");
if (engine.Verify()==true)
{ engine.Repair(nul,
RepairOption.RecoverCoruptedRows);
}
B. SqlCeEngine engine = new SqlCeEngine("Data Source =
'Datafile.sdf'");
if (engine.Verify()==false)
{ engine.Repair(nul,
RepairOption.RecoverCoruptedRows);
}
C.SqlCeEngineengine = new SqlCeEngine("Data Source =
'Datafile.sdf'");
if (engine.Verify()==true)
{ engine.Repair("DataSource='Datafile.sdf'",
RepairOption.RecoverCoruptedRows);
}
D.SqlCeEngineengine = new SqlCeEngine("Data Source =
'Datafile.sdf'");
if (engine.Verify()==false)
{ engine.Repair("DataSource='Datafile.sdf'",
RepairOption.RecoverCoruptedRows);
}
-
8/22/2019 Exam 70-540
27/100
Question: 29
You create a MicrosoftWindows Mobilebased application. The application usesa Microsoft SQL
Mobile database named SalesData.sdf.
You arerequired to createtwo tables that are named Customers and Sales. The Sales tablemust
have aforeign key relationship to the Customers table.
You write the folowing code segment. (Linenumbers areincluded for reference only.)
01SqlCeConnection con = newSqlCeConnection ("DataSource='SalesData.sdf'");
02con.Open();
03SqlCeCommandcmd = con.CreateCommand();
04
05con.Close();
You need to create theCustomersand Sales tables.
A. cmd.CommandText = "CREATE TABLE Customers(CustIDint
PRIMARY KEY,CustomerName nvarchar(25)";
cmd.ExecuteNonQuery();
cmd.CommandText= "CREATE TABLE Sales(SalesIDint,
CustID int REFERENCES Customers(CustID)";
cmd.ExecuteNonQuery();
B. cmd.CommandText = "CREATE TABLE Customers (CustID int,
CustomerName nvarchar(25)";
cmd.ExecuteNonQuery();
cmd.CommandText= "CREATE TABLESales(SalesIDint PRIMARY KEY,
CustID int REFERENCES Customers(CustID)";
cmd.ExecuteNonQuery();
C.cmd.CommandText = "CREATE TABLE Customers
-
8/22/2019 Exam 70-540
28/100
(CustID int PRIMARY KEY,CustomerNamenvarchar(25)";
cmd.ExecuteNonQuery();
cmd.CommandText= "CREATE TABLESales
(SalesID int PRIMARYKEY, CustIDint)";
cmd.ExecuteNonQuery();Reset Instructions Calculator.
D.cmd.CommandText = "CREATE TABLE Customers (CustID int,
CustomerName nvarchar(25)";
cmd.ExecuteNonQuery();
cmd.CommandText= "CREATE TABLE Sales(SalesIDint,
CustID int REFERENCES Customers(CustID)";
cmd.ExecuteNonQuery();
Question: 30
You arecreating a Microsoft Windows Mobilebased application. The application connectstoa
Microsoft SQL Mobile database by using Integrated Windows Authentication.
The SQLMobiledatabasemust synchronize its data witha database named AdventureWorks.
The AdventureWorks database is hosted on a Microsoft SQL Server2005 database server
named Accounts.
The Accountsserver contains a publication named PubAdvWorks for theAdventureWorks
database.
You create a SqlCeReplicationobject named rep.
You need to setthe properties ofthe rep objectto facilitate merge replication.
Which code segment should you use?
A. rep.Publication ="PubAdvWorks";
rep.PublisherAddress ="Accounts";
rep.PublisherDatabase ="AdventureWorks";
B. rep.Publication ="PubAdvWorks";
rep.Publisher = "Accounts";
-
8/22/2019 Exam 70-540
29/100
rep.PublisherDatabase ="AdventureWorks";
rep.PublisherSecurityMode = SecurityType.NTAuthentication;
C.rep.Publication = "PubAdvWorks";
rep.HostName= "Accounts";
rep.PublisherDatabase ="AdventureWorks";
rep.PublisherSecurityMode = SecurityType.NTAuthentication;
D.rep.Publication = "PubAdvWorks";
rep.PublisherNetwork =NetworkType.DefaultNetwork;
rep.Publisher = "Accounts";
rep.HostName= "Accounts";
rep.PublisherDatabase ="AdventureWorks";
Question: 31
You arecreating a Microsoft Windows Mobilebased application. The application connectstoa
Microsoft SQL Mobile database. The application begins a transaction byusing a
SqlCeTransaction object namedtranSales.
The databasefile mustbe copiedfrom the Windows Mobilebaseddevice.
You need to ensure that the folowingrequirements aremet:
The databasetransaction is commited.
The copied databasefile on the desktopcomputer retains althe changesthat are made by the
most recentcommitoperation.
Which code segment should you use?
A. tranSales.IsolationLevel = IsolationLevel.Serializable;
tranSales.Commit();
B. tranSales.IsolationLevel = IsolationLevel.ReadCommited;
tranSales.Commit();
C.CommitModemode= CommitMode.Defered;
tranSales.Commit(mode);
-
8/22/2019 Exam 70-540
30/100
D.CommitModemode = CommitMode.Immediate;
tranSales.Commit(mode);
Question: 32
You arecreating a Microsoft Windows Mobile-based application. Theapplication connects to a
Microsoft SQL Server 2005 database named Accounts. The Accountsdatabasehas a table
named Customers.
You write the folowing code segment.
string conStr= "DataSource =Server-Test;
Initial Catalog =Accounts;User Id=
userName;Password = pasword";
SqlCeRemoteDataAccess rda =
new SqlCeRemoteDataAccess(
"htp:/Server-Test/sqlmobile/sqlcesa30.dl",
"userName", "password",
"Data Source=MyDatabase.sdf");
The application mustperform thefolowing tasks:
Create a new table namedCustomerDets ina local MicrosoftSQL Mobiledatabase.
Copy data from theCustomerstable to the CustomerDets table.
Track any changesto thedata in the CustomerDetstable.
You need to ensure that the application meets the outlined requirements.
Which code segment should you use?
A. rda.Pul("Customers", "Select * from Customers", conStr,
RdaTrackOption.TrackingOnWithIndexes, "CustomerDets");
-
8/22/2019 Exam 70-540
31/100
B. rda.Pul("CustomerDets","Select* from Customers", conStr,
RdaTrackOption.TrackingOn);
C.rda.Pul("CustomerDets", "Select *from Customers", conStr,
RdaTrackOption.TrackingOfWithIndexes);
D.rda.Pul("Customers", "Select* from Customers",conStr,
RdaTrackOption.TrackingOf, "CustomerDets");
Question: 33
You arecreating a Microsoft Windows Mobilebased application.
The application mustmeetthe folowing requirements:
It mustcreate a MicrosoftSQL Mobiledatabase file named Test.sdf.
If the databasefile already exists, itmust be overwriten.
You need ensurethat theapplication meets the outlined requirements.
Which code segment should you use?
A. string conStr = "Data Source = 'Test.sdf'";
if (File.Exists("Test.sdf")== false) {
SqlCeEngine engine = new SqlCeEngine(conStr);
engine.CreateDatabase();
}
B. string conStr = "Data Source = 'Test.sdf'";
SqlCeEngine engine = new SqlCeEngine(conStr);
engine.CreateDatabase();
C.File.Delete("Test.sdf");
string conStr= "DataSource = 'Test.sdf'";
SqlCeEngine engine = new SqlCeEngine(conStr);
engine.CreateDatabase();
D.if (File.Exists("Test.sdf")
File.Delete("Test.sdf");
-
8/22/2019 Exam 70-540
32/100
string conStr= "DataSource = 'Test.sdf'";
SqlCeEngine engine = new SqlCeEngine(conStr);
engine.CreateDatabase();
Question: 34
You arecreating a Microsoft Windows Mobilebased application. The application usesdata froma
Microsoft SQL Mobile database named Sales.sdf. The database contains a tablenamed
Customers.Thetable has a field namedStatusoftypevarchar.
You write the folowing code segment.
SqlCeConnection cnn =new SqlCeConnection();
cnn.ConnectionString ="Data Source='Sales.sdf'";
cnn.Open();
SqlCeCommand cmd = new SqlCeCommand();
cmd.Connection= cnn;
cmd.CommandText =
"Update Customers set Status='A' where Status='I'";
You need to execute the SqlCeCommandobject thatwil alow youto displaythe total numberof
customerstatus updates.
Which code segment should you use?
A. cmd.ExecuteScalar();
B. cmd.ExecuteNonQuery();
C.cmd.ExecuteReader(CommandBehavior.SingleRow);
D.cmd.ExecuteResultSet(ResultSetOptions.None);
-
8/22/2019 Exam 70-540
33/100
Question: 35
You arecreating a Microsoft Windows Mobilebased application.
You write the folowing code segment.
SqlCeConnection con = new SqlCeConnection
("DataSource = 'DataFile.sdf'");
try{
con.Open();
.
}
.
You need to catch theexception that is thrown if the database file is unavailable.
Which code segment should you use?
A. catch(ArgumentException exc){
.
}
B. catch(IOException exc){
.
}
C.catch (SqlCeException exc) {
.
}
D.catch (FileNotFoundException exc) {
.
}
-
8/22/2019 Exam 70-540
34/100
Question: 36
You create a MicrosoftWindowsMobilebased application.
You need to enable performance counters and logging for the application and log theinformation
to a separate file.
What should you do?
A. Rebuild theapplication by usingthe /log:filename command option.
B. Use the Devenvcommand to specify the log file for the application.
C.Create an instance of the TraceListenerclass inthe application.
D.Set the HKLM\Software\Microsoft\.NETCompactFramework\Diagnostics\Logging\UseApp
registry keyto1.
Question: 37
You create a Microsoft .NET Compact Frameworkapplication forMicrosoft Windows
Mobilebased devices.
You need to create a deploymentpackage forthe WindowsMobilebased application.
What should you do?
A. In the main MicrosoftVisualStudio2005solution for the application, adda Smart DeviceCAB
project. Add theprimaryoutput of the Smart Device project to the SmartDevice CAB project.
B. In the main MicrosoftVisualStudio2005solution for the application, add a CABproject. Add
the primary output of the Smart Device project to the CAB project.
C.Create an empty text file named App.CAB. Add it to theSmart Device project andset the Build
Action propertyfor theApp.CABfile to Content.
D.Runthe Cabwiz.exefile andreferencethe Microsoft VisualStudio2005solution for the
application.
-
8/22/2019 Exam 70-540
35/100
Question: 38
You arecreating a Microsoft Windows Mobilebased applicationby usingMicrosoft .NET Compact
Framework 2.0.
The Windows Mobilebased application wilbe deployed to multiple Windows Mobiledevice
platforms.
You open DeviceEmulator Manager and atempt to access the emulators for thedevices. You
discover that the emulators areclosed.
You need to ensure that you can test the application for each deviceplatform.
What should you do?
A. Restore animagefor each device emulator.
B. Connect to each device emulator.
C.Cradleeach device emulator.
D.Reset each device emulator.
Question: 39
You create a MicrosoftWindows Mobilebased applicationthat retrieves data from aWeb service.
You test the Windows Mobilebasedapplication ina Windows Mobile 5.0 emulator. The
application fails to connectto the Web service. Youdiscoverthat Microsoft ActiveSyncisnot
instaled on thedesktop computer.
You need to ensure that the application connects to the Web servicefrom the emulator.
Which twotasksshould you perform?(Each corectanswerpresentspartofthe solution. Choose
two.)
A. Instal Microsoft Web Services Enhancements 3.0.
B. Instal theMicrosoft Virtual MachineNetwork Services driverfor theemulator.
C.Configurethe TCP setings forthe emulator to use TCPConnectTransport and configure the
emulator to use astatic IP address.
D.Configurethe connection setings toalow DMA connections.
-
8/22/2019 Exam 70-540
36/100
E. Configure the connection setings to connect thecomputer to the Internet.
Question: 40
You create a Microsoft .NET Compact Frameworkassemblyfor Microsoft Windows Mobilebased
devices.
Alassemblies mustbestrong named. The keypair fileisnamed ContosoKeyPair.snk.
You need to ensure that the outlinedrequirementismet by using Microsoft Visual Studio 2005.
What should you do?
A. Authenticode sign the assembly with the ContosoKeyPair.snk file.
B. Addthe ContosoKeyPair.snk file to the project, and set theBuildAction propertytoEmbedded
Resource.
C.Set the AssemblyKeyFile property to thelocation of theContosoKeyPair.snk file.
D.Add the ContosoKeyPair.snk filetothe project, and set the Build Action property to Content.
Question: 41
You arecreating a Microsoft Windows Mobilebased animation application.
You create a disposable class namedUnmanagedResource to manage drawing operations on
the screen.
You create a static method in theUnmanagedResource class named LoadResource that loads
unmanaged resources.
You must release al the unmanaged resources when the folowingsituationsarise:
You finish using al theunmanaged resources.
Anexception occurswhen you use theUnmanagedResource class.
You need to identify thecode segment that meetsthe outlined requirements.
Which code segment should you use?
A. using( UnmanagedResourceur = UnmanagedResource.LoadResource (res) {
-
8/22/2019 Exam 70-540
37/100
.
}
B. UnmanagedResource ur= UnmanagedResource.LoadResource (res);
using ( ur ) {
.
}
C.UnmanagedResourceur =UnmanagedResource.LoadResource (res);
try{
.
}
finaly {
ur.Dispose ();
}
D.UnmanagedResource ur =nul;
try{
ur = UnmanagedResource.LoadResource (res);
.
}
catch (Exception ) {
ur.Dispose ();
}
Question: 42
You arecreating a Microsoft Windows Mobilebased application. The application usesa Web
service. The Web serviceacceptsa customer IDfrom the applicationand returns
the details of the customer.
The Web servicewil throw an ArgumentException exception ifthe customer ID doesnot exist.
You need to write acatch block in theapplication to handle theexception.
Which code segment should you use?
-
8/22/2019 Exam 70-540
38/100
A. catch(SoapException exc){
if (SoapException.IsServerFaultCode(exc.Code) {
/Handle exception
}
}
B. catch(SoapException exc){
if (SoapException.IsClientFaultCode(exc.Code) {
/Handle exception
}
}
C.catch (ArgumentExceptionexc) {
/Handle exception
}
D.catch (SoapHeaderException exc) {
/Handle exception
}
Question: 43
You arecreating a Microsoft Windows Mobilebased application. The application connectstoa
Web server located atwww.contoso.com. The Webserver contains a Webpagenamed
data.aspx.Thedata.aspx page accepts thefirstname and the lastnameofa user anddisplays
personalized messages tothe user.
The application contains aWindows Form.Theform wil accept the first name and the last name
of theuserin the text boxes named txtFirstName and txtLastName, respectively.
You need to ensure that users can retrieve personalizedmessages fromthe Webserver.
Which code segment should you use?
A. string fields = "firstName:" + this.txtFirstName.Text +
-
8/22/2019 Exam 70-540
39/100
" & lastName:"+ this.txtLastName.Text;
byte[] bytes= Encoding.Unicode.GetBytes(fields);
HtpWebRequestreq= (HtpWebRequest)System.Net.WebRequest.
Create ("htp:/ www.contoso.com/data.aspx");
req.ContentType = "application/xml";
req.Method ="PUT";
re q.ContentLength =bytes.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(bytes, 0, 0);
os.Close();
B. string fields = "firstName=" + this.txtFirstName.Text+
" & lastName=" +this.txtLastName.Text;
byte[] bytes= Encoding.Unicode.GetBytes(fields);
HtpWebRequestreq= (HtpWebRequest)System.Net.WebRequest.
Create("htp:/www.contoso.com/data.aspx");
req.ContentType = "application/x-www-form-urlencoded";
req.Method ="POST";
req.ContentLength = bytes.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
os.Close();
C.Reset Instructions Calculator.string fields = "firstName:" + this.txtFirstName.Text +
" & lastName:"+ this.txtLastName.Text;
byte[] bytes= Encoding.Unicode.GetBytes(fields);
HtpWebRequestreq= (HtpWebRequest)System.Net.
WebRequest.Create ("www.contoso.com/data.aspx");
req.ContentType = "text/HTML";
req.Method ="POST";
req.ContentLength = bytes.Length;
-
8/22/2019 Exam 70-540
40/100
System.IO.Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes .Length);
os.Close();
D.string fields = "firstName=" +this.txtFirstName.Text+
" & lastName=" +this.txtLastName.Text;
byte[] bytes= Encoding.Unicode.GetBytes(fields);
HtpWebRequestreq= (HtpWebRequest)System.Net.
WebRequest.Create("www.contosso.com/data.aspx");
req.ContentType = "application/x-www-form-urlencoded";
req.Method ="PUT";
req.ContentLength = bytes.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
os.Close();
Question: 44
You arecreating a Microsoft Windows Mobilebased application. The application acquires serial
data from a GPS receiver.
The application mustupdate a display window whenever the data is received.
You need to select the mechanismto update thedisplay.
Which mechanism should you choose?
A. Retrieve theSerialPort.DataBits property value and updatethe display if thevalue is non-zero.
B. Handle the SerialPort.DataReceived eventand update the display whenever theevent is fired.
C.Retrievethe SerialPort.ReadBuferSizeproperty valueand update the display ifthe value is
non-zero.
D.Handle theSerialPort.PinChanged event andupdatethe display whenever the event is fired.
Question: 45
-
8/22/2019 Exam 70-540
41/100
You arecreating a Microsoft Windows Mobilebased application. You are required todefinea
method named GetRequestDetailsthat accepts aUri objectas a parameter.
You write the folowing code segment.
publicvoidGetRequestDetails (Uri uri )
{ HtpWebRequestreq =
( HtpWebRequest)WebRequest.Create ( uri );
.
}
You need to identify theinstances ofthe Uri object thatcanbe passed asan argument tothe
GetRequestDetails method.
What are two possible ways to achievethis goal? (Each corect answer presents a complete
solution. Choose two.)
A. Uriuri = new Uri("htp: /www.contoso.com");
B. Uri uri = new Uri("htps: /www.contoso.com/MyFile.txt");
C.Uri uri = newUri("ftp: /www.contoso.com");
D.Uri uri = newUri(" tcp :/www.contoso.com/MyFile.txt");
E. Uri uri = new Uri("file: /Myfile.txt");
Question: 46
You arecreating a Microsoft .NET CompactFramework application.Theapplication wil
communicate with aMicrosoft Message Queuing (MSMQ) server.
The application mustreceivea message from a localqueue. The message contains data from a
class namedOrder.
The Order classhas the folowingdefinition.
-
8/22/2019 Exam 70-540
42/100
publicclass Order {
publicint CustomerID ;
publicstring CustomerName ;
publicstringItem;
}
You need to retrievethe message from the local queue by extracting the Order classdata.
Which code segment should you use?
A. MessageQueue q= new MessageQueue (".\myqueue");
q.Formater =new XmlMessageFormater(new string[]{"Order"});
Message m =q.Receive ();
Order o = (Order) m.Body;
B. MessageQueue q= new MessageQueue (".\myqueue");
q.Formater =new XmlMessageFormater(new Type[]{typeof(Order)});
Message m =q.Receive ();
Order o = (Order) m.Body;
C.MessageQueue q = new MessageQueue (".\myqueue");
q.Formater =new XmlMessageFormater(new Type[]{typeof(Message)});
Message m =q.Receive ();
Order o = (Order) q.Formater.Read (m);
D.Reset Instructions Calculator.MessageQueueq =new MessageQueue (".\myqueue");
q.Formater =new XmlMessageFormater(new string[]{"Message"});
Message m =q.Receive ();
Order o = (Order) q.Formater.Read (m);
Question: 47
You arecreating a Microsoft Windows Mobilebased application. The application wil use an XML
Web service.
-
8/22/2019 Exam 70-540
43/100
The Web serviceexposesa singlemethodthat has thefolowing codesegment.
GetWeather(string city, string country);
The application mustmeetthe folowing requirements:
Retrieve data from the Web service.
Respond to user interactions while retrieving data.
You need to write the code segment tomeetthe outlined requirements.
Which code segment should you use?
A. private void HandleServiceResult(IAsyncResultresult) {}
public voidCalService()
{ IAsyncResult result =
service.BeginGetWeather(" Springfield ", " USA", nul, nul);
HandleServiceResult(result);
}
B. private void HandleServiceResult(stringresult) {}
public voidCalService(){
string result =service.GetWeather(" Springfield ", " USA ");
HandleServiceResult(result);
}
C.private void HandleServiceResult(IAsyncResult result){}
public voidCalService()
{ CalServiceback calback
=
newCalServiceback(CalbackProc);
service.BeginGetWeather(" Springfield ", " USA ", calback,nul);
-
8/22/2019 Exam 70-540
44/100
}
publicvoidCalbackProc(IAsyncResultresult)
{ HandleServiceResult(result);
}Reset InstructionsCalculator.
D.private void HandleServiceResult(IAsyncResult result){}
public voidCalService()
{ IAsyncResult result =
service.BeginGetWeather(" Springfield ", " USA", nul, nul);
service.EndGetWeather(result);
HandleServiceResult(result);
}
Question: 48
You arecreating a Microsoft Windows Mobilebased application.
The application connects to a remote servernamed www.contoso.comonport 80.
You need to retrievedata fromthe remote serverby usingthe TcpClient class.
Which code segment should you use?
A. TcpClient tcpClient= new TcpClient();
NetworkStream netStream = tcpClient.GetStream();
Byte[] readBytes = newbyte[256];
do{
netStream.Read(readBytes, 0, 0);
}
while (netStream.DataAvailable);
tcpClient.Close();
netStream.Close();
-
8/22/2019 Exam 70-540
45/100
B. TcpClient tcpClient= new TcpClient("www.contoso.com", 80);
NetworkStream netStream = tcpClient.GetStream();
Byte[] readBytes = newbyte[256];
do{
netStream.Read(readBytes, 0, readBytes.Length);
}
while (netStream.DataAvailable);
tcpClient.Close();
netStream.Close();
C.TcpClient tcpClient = new TcpClient("www.contoso.com",80);
tcpClient.Connect("www.contoso.com", 80);
NetworkStream netStream = tcpClient.GetStream();
Byte[] readBytes = newbyte[256];
do{
netStream.Read(readBytes, 0, 0);
}
while (netStream.DataAvailable);
tcpClient.Close();
netStream.Close();Reset Instructions Calculator.
D.TcpClient tcpClient =newTcpClient();
tcpClient.Connect("www.contoso.com", 80);
Socket socket= new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
NetworkStream netStream = new NetworkStream(socket);
Byte[] readBytes = newbyte[256];
do{
netStream.Read(readBytes, 0, readBytes.Length);
}
while (netStream.DataAvailable);
tcpClient.Close();
-
8/22/2019 Exam 70-540
46/100
netStream.Close();
Question: 49
You arecreating anapplication forMicrosoft Windows Mobilebaseddevices.
The application contains aWindowsForm.Theformcontains a private variable named state of
the type SystemState.
You need to retrievethe phone number of an incoming cal when the phonerings.
Which twotasksshould you perform?(Each corectanswerpresentspartofthe solution. Choose
two.)
A. Write the folowing code segment inthe constructorofthe form.
state = new SystemState
(SystemProperty.PhoneIncomingCalerContact);
state.Changed += new ChangeEventHandler(state_Changed); B.
Write thefolowing codesegment in the constructor ofthe form.
state = new SystemState
(SystemProperty.PhoneIncomingCalerNumber);
state.Changed += new ChangeEventHandler(state_Changed);C.
Write the folowing code segmentin theconstructor of the form.
state = new SystemState
(SystemProperty.PhoneTalkingCalerContact);
state.Changed += new ChangeEventHandler(state_Changed);
D.Writethe folowing code segment in theconstructor of theform.
state = new SystemState
(SystemProperty.PhoneTalkingCalerNumber);
state.Changed += new ChangeEventHandler(state_Changed);
E. Reset Instructions Calculator.Add the folowing eventhandlerin the form.
void state_Changed(object sender, ChangeEventArgs args){
Contact contact =(Contact)args.NewValue;
string number = contact.MobileTelephoneNumber;
-
8/22/2019 Exam 70-540
47/100
}
F. Add thefolowing eventhandlerin theform.
void state_Changed(object sender, ChangeEventArgs args){
string number= args.NewValue.ToString();
}
Question: 50
You arecreating a Microsoft Windows Mobilebased application. The application wilalow users
to send e-mail [email protected].
ThetxtEmailtext box control contains thee-mailmessagetobesent.
You need to send the e-mail messageby usinganexisting e-mail account.
Which code segment should you use?
A. private void btnSendEmail_Click(object sender, EventArgs e)
{ EmailMessage emailMessage = new EmailMessage();
emailMessage.BodyText =this.txtEmail.Text;
emailMessage.Send("[email protected]");
}
B. private void btnSendEmail_Click(object sender, EventArgs e)
{ OutlookSessionoutlookSession =new OutlookSession();
EmailAccountemailAccount =outlookSession.EmailAccounts[0];
EmailMessage emailMessage = new EmailMessage();
emailMessage.BodyText =this.txtEmail.Text;
emailMessage.Send("[email protected]");
}
C.private void btnSendEmail_Click(object sender, EventArgs e)
{ OutlookSessionoutlookSession =new OutlookSession();
-
8/22/2019 Exam 70-540
48/100
EmailAccountemailAccount =outlookSession.EmailAccounts[0];
EmailMessage emailMessage = new EmailMessage();
emailMessage.BodyText =this.txtEmail.Text;
emailMessage.To.Add(new Recipient("[email protected]");
emailMessage.Send(emailAccount);
}
D.private void btnSendEmail_Click(object sender, EventArgs e)
{ EmailMessage emailMessage = new EmailMessage();
emailMessage.BodyText =this.txtEmail.Text;
emailMessage.To.Add(new Recipient("[email protected]");
emailMessage.Send ( emailMessage.From .Address);
}
Question: 51
You arecreating a Microsoft .NET CompactFramework application that wil interoperate with a
native DLL.
The GetDatafunction defined inthe native DLLcontainsthe folowing code segment.
typedef structDATA_STRUCT {
DWORD id;
WORD data1;
WORD data2;
}
DATA_STRUCT;
extern "C"
__declspec(dlexport) voidGetData(DATA_STRUCT *pData);
You need to cal the native GetData function.
-
8/22/2019 Exam 70-540
49/100
What are two possible ways to achievethis goal? (Each corect answer presents a complete
solution. Choose two.)
A. public class DATA_STRUCT {
public uint id;
public ushort data1;
public ushort data2;
}
[DlImport("NativeDl.dl")]
privatestaticextern void GetData(DATA_STRUCT data);
B. public struct DATA_STRUCT{
uintid;
ushort data1;
ushort data2;
}
[DlImport("NativeDl.dl")]
privatestaticextern void GetData(ref DATA_STRUCTdata);
C.Reset Instructions Calculatorpublic class DATA_STRUCT{
public uint id;
public ushort data1;
public ushort data2;
}
[DlImport("NativeDl.dl")]
privatestaticextern void GetData(ref DATA_STRUCTdata);.
D.public struct DATA_STRUCT {
uintid;
ushort data1;
ushort data2;
}
-
8/22/2019 Exam 70-540
50/100
[DlImport("NativeDl.dl")]
privatestaticextern void GetData(DATA_STRUCT data);
Question: 52
You arecreating a Microsoft .NET CompactFramework application.
The application mustusean existing nativeCOM interface named IOrders andan enumeration
named OrderStatus. The interfaceand theenumeration are inthe Orders.tlb file.
You need to import theOrders.tlb fileintothe application.
What should you do?
A. Create managed definitions of the IOrders interface and the OrderStatusenumeration by
executing the Type Library Importer (tlbimp.exe) filethat uses theOrders.tlb file as a
command-line parameter. Adda reference to the resulting assembly inthe MicrosoftVisual
Studio 2005 projectfor theapplication.
B. Addthe Orders.tlb file tothe MicrosoftVisualStudio2005project for theapplication.On the
Filemenu, select theProperties option,and thensetthe Build Action property to the
Embedded Resource enumeration.
C.Rewrite theIOrders interface and the OrderStatusenumeration intoa managed code
assembly. Add a reference to the resultingassemblyin the Microsoft Visual Studio 2005
projectfor theapplication.
D.Add a reference to the nativeDLLin the Microsoft Visual Studio 2005 project for the
application.
Question: 53
You create a Microsoft .NET Compact Frameworkapplication thatinteroperates with a native
DLL.
The application cals theMicrosoft Win32 EnumWindows API.
-
8/22/2019 Exam 70-540
51/100
The native definition forEnumWindows contains the folowing code segment.
BOOL EnumWindows(
WNDENUMPROC lpEnumFunc ,
LPARAMlParam ;
)
The native definition forWNDENUMPROC contains the folowing code segment.
BOOL CALLBACK EnumWindowsProc (
HWNDhwnd ,
LPARAMlParam ;
)
The Platform Invoke definitioncontainsthe folowing code segment.
[ DlImport ("coredl.dl", SetLastEror = true)]
publicstaticextern bool EnumWindows
( IntPtr lpEnumFunc , uint lParam );
The managed calback definition contains the folowing code segment.
public int EnumWindowsCalbackProc ( IntPtr hwnd , IntPtr lParam )
{ System.Diagnostics.Debug.WriteLine ("Window: " +
hwnd.ToString ();
return1;
}
You need to write amanaged functionthat cals thenative API.
Which code segment should you use?Reset Instructions Calculator.
A. public delegate int EnumWindowsProc ( IntPtr hwnd, IntPtr lParam);
publicvoidInitializeCalback ()
-
8/22/2019 Exam 70-540
52/100
{ EnumWindowsProccalbackDelegate
=
new EnumWindowsProc (EnumWindowsCalbackProc);
IntPtr calbackDelegatePointer =
Marshal.GetFunctionPointerForDelegate(calbackDelegate);
EnumWindows( calbackDelegatePointer , 0);
}
B. public delegate int EnumWindowsProc(IntPtrhwnd, IntPtrlParam);
public voidInitializeCalback()
{ EnumWindowsProccalbackDelegate
=
new EnumWindowsProc(EnumWindowsCalbackProc);
IntPtr calbackDelegatePointer =
Marshal.GetIDispatchForObject(calbackDelegate);
EnumWindows(calbackDelegatePointer,0);
}
C.public delegate intEnumWindowsProc(IntPtr hwnd, IntPtr lParam);
publicvoidInitializeCalback ()
{ IntPtrcalbackDelegatePointer
=
Marshal.GetFunctionPointerForDelegate
(EnumWindowsProc)EnumWindowsCalbackProc);
EnumWindows(calbackDelegatePointer,0);
}
D.Microsoft.WindowsCE.Forms.MessageWindow calbackWindow =
new Microsoft.WindowsCE.Forms.MessageWindow();
public delegate int EnumWindowsProc(IntPtr hwnd, IntPtr lParam);
publicvoidInitializeCalback
{ EnumWindowsProccalbackDelegate = new
-
8/22/2019 Exam 70-540
53/100
EnumWindowsProc(EnumWindowsCalbackProc);
calbackDelegate.Invoke(calbackWindow.Hwnd, IntPtr.Zero);
}
Question: 54
You arecreating a Microsoft Windows Mobilebased application. The application must receive
Windows messages from a nativeapplication.
You write the folowing code segment.
publicclass MsgWin : MessageWindow
{ privateconst intWM_APP= 0x8000;
publicEventHandler MessageReceived;
}
You need to add code to the MsgWin class toensure that the applicationraises the
MessageReceived event whena WM_APP message is received.
Which code segment should you use?
A. protected overide void WndProc(ref Message m) {
if (m.Msg!= WM_APP) {
if (MessageReceived != nul) MessageReceived(this, nul);
}
base.WndProc(ref m);
}
B. protected overide void WndProc(ref Message m) {
if (m.Msg== WM_APP) {
if (MessageReceived != nul) MessageReceived(this, nul);
-
8/22/2019 Exam 70-540
54/100
}
base.WndProc(ref m);
}
C.protected overidevoid WndProc(refMessage m) {
if (m.Result == (IntPtr)WM_APP) {
if (MessageReceived != nul) MessageReceived(this, nul);
}
base.WndProc(ref m);
}
D.Reset Instructions Calculator.protected overide void WndProc(ref Message m) {
if (m.LParam == ( IntPtr ) WM_APP ) {
if (MessageReceived != nul) MessageReceived(this, nul);
}
base.WndProc(ref m);
}
Question: 55
You arecreating a Microsoft Windows Mobilebased application. The application wil presenta
Notification bubble afterfinishing a long-running process ina separate thread.
You write the folowing code.
Microsoft.WindowsCE.Forms.Notification notify = newMicrosoft.WindowsCE.Forms.Notification();
string text = "";
text+= "";
text += "Start now";
text += "Postpone";
text+= "";
text+= "";
-
8/22/2019 Exam 70-540
55/100
text+= "";
notify.Text= text;
notify.ResponseSubmited +=new
ResponseSubmitedEventHandler(notify_ResponseSubmited);
The notify_ResponseSubmited event handler mustmeetthe folowing requirements:
Identify the selectionin the drop-down listbox.
Eitherdisplaythe DataDetailsForm formimmediatelyor temporarily hide the Notification bubble
and display a Notificationiconon the title bar.
You need to write the code segment tomeetthe outlined requirements.
Which code segment should you use?
A. int choice =Convert.ToInt32(e.Response.Substring(12, 1);
if (choice == 1) {
notify.Visible= false;
DataDetailsFormform = new DataDetailsForm();
form.Show();
}
else
{ notify.InitialDuration = 0;
notify.Visible= true;
}
B. int choice =Convert.ToInt32(e.Response.Substring(12, 1);
if (choice == 0) {
notify.Visible= false;
DataDetailsFormform = new DataDetailsForm();
form.Show();
}
-
8/22/2019 Exam 70-540
56/100
else
{ notify.InitialDuration = 0;
notify.Visible= true;
}
C.int choice = Convert.ToInt32(e.Response.Substring(12, 1);
if (choice == 0) {
notify.Visible= true;
DataDetailsFormform = new DataDetailsForm();
form.Show();
}
else {
notify.InitialDuration = 10;
notify.Visible= false;
}
D.int choice = Convert.ToInt32(e.Response.Substring(12, 1);
if (choice == 0) {
DataDetailsFormform = new DataDetailsForm();
form.Show();
}
else {
notify.InitialDuration = 0;
}
Question: 56
You arecreating a Microsoft Windows Mobilebased application. The application alows adding
tasks to theTo-Do list in the Windows Mobile device.
You need to add a new task that displaysthe text "Meeting"in the Tasks window. Youalso need
to ensure thatthistask is displayedwhen the Tasksarefiltered toshowBusiness and Work
tasks.
-
8/22/2019 Exam 70-540
57/100
Which code segment should you write?
A. Task task = new Task();
task.Subject = "Meeting";
task.Properties.Add("Work");
task.Properties.Add("Business");
OutlookSession session =newOutlookSession();
session.Tasks.Items.Add(task);
B. Task task = new Task();
task.Body = "Meeting";
task.Properties.Add("Work");
task.Properties.Add("Business");
OutlookSession session =newOutlookSession();
session.Tasks.Items.Add(task);
C.Task task =new Task();
task.Subject = "Meeting";
task.Categories= "Work,Business";
OutlookSession session =newOutlookSession();
session.Tasks.Items.Add(task);
D.Task task =new Task();
task.Body = "Meeting";
task.Categories= "Work,Business";
OutlookSession session =newOutlookSession();
session.Tasks.Items.Add(task);
Question: 57
You arecreating a Microsoft Windows Mobilebased application.
You write the folowing code segment.
-
8/22/2019 Exam 70-540
58/100
publicstructAccountData {
publicint AccountId;
publicfloat Balance;
}
const int WM_COPYDATA= 0x0200;
You need to send data inan AccountData structure to a separate process by usingthe
WM_COPYDATAWindows message andthe folowing P/Invokedeclaration:
[DlImport("coredl")]
static extern IntPtr SendMessage(IntPtr hWnd,uint Msg, IntPtrwParam, refCOPYDATASTRUCT
cds);
Which twocode segments should you use? (Each corect answer presents part of the solution.
Choose two.)
A. public void SendMsg(IntPtr handle,AccountDataaccData)
{ COPYDATASTRUCT data = new COPYDATASTRUCT();
data.dwData= Marshal.SizeOf(accData);
data.lpData= accData;
SendMessage
(handle,WM_COPYDATA, (IntPtr)0, ref data);
}
B. public void SendMsg(IntPtr handle,AccountDataaccData)
{ COPYDATASTRUCT data = new COPYDATASTRUCT();
data.dwData= Marshal.SizeOf(accData);
IntPtr pData = Marshal.AlocHGlobal(data.dwData);
Marshal.StructureToPtr(accData, pData, false);
data.lpData= pData;
-
8/22/2019 Exam 70-540
59/100
SendMessage(handle, WM_COPYDATA, (IntPtr)0,ref data);
}
C.public struct COPYDATASTRUCT {
public int dwData;
public int cbData;
public AccountData lpData;
}
D.public struct COPYDATASTRUCT {
public int dwData;
public int cbData;
public IntPtr lpData;
}
Question: 58
You arecreating a Microsoft Windows Mobilebased applicationfor a MicrosoftWindows Mobile
powered Pocket PC Phone Edition device.
The application mustperform thefolowing tasks:
Monitor thestatus of the phone service coverageonthe device.
Display awarning message ifthe phonestatus is of.
You need to ensure that the application meets the outlined requirements.
Which code segment should you use?
A. SystemStatestate =new
SystemState(SystemProperty. PhoneCelBroadcast);
state.Changed += new ChangeEventHandler(state_Changed);
void state_Changed(object sender, ChangeEventArgs args)
{ boolresult= (bool)state.CurentValue;
if (!result) {
MessageBox.Show("The phoneisof");
}
}
-
8/22/2019 Exam 70-540
60/100
B. SystemStatestate =new
SystemState(SystemProperty. PhoneCelBroadcast);
state.Changed += new ChangeEventHandler(state_Changed);
void state_Changed(object sender, ChangeEventArgs args){
int result = (int) state.ComparisonValue;
if (result ==0) {
MessageBox.Show("The phoneisof");
}
}
C.Reset Instructions CalculatorSystemState state = new
SystemState(SystemProperty.PhoneGprsCoverage );
state.Changed += new ChangeEventHandler(state_Changed);
void state_Changed(object sender, ChangeEventArgs args)
{ boolresult= (bool)args.NewValue;
if (result) {
MessageBox.Show("The phoneisof");
}
}.
D.SystemState state= new
SystemState(SystemProperty.PhoneGprsCoverage);
state.Changed += new ChangeEventHandler(state_Changed);
void state_Changed(object sender, ChangeEventArgs args){
int result = (int) args.NewValue;
if (result ==0) {
MessageBox.Show("The phoneisof");
}
}
Question: 59
-
8/22/2019 Exam 70-540
61/100
You arecreating a Microsoft .NET Compact Frameworkapplication fora Microsoft Windows
Mobilebased device.
The application cals a nativeDLLto retrieve data. The nativeDLLexports the folowing function.
void GetData(BYTE *pData);
The application contains the folowing managed function.
publicvoidUseData(byte[] data)
You need to retrievedata fromthe nativeDLL.You also need to pass the retrieveddata to the
UseData function.
Which code segment should you use?
A. [DlImport("NativeLib.dl")]
public staticextern void GetData(IntPtr data);
public voidPassObject() {
byte[] bufer = new byte[1024];
GCHandle pbufer =GCHandle.Aloc(bufer, GCHandleType.Pinned);
GetData(pbufer.AddrOfPinnedObject();
UseData(bufer);
pbufer.Free();
}
B. [DlImport("NativeLib.dl")]
public staticextern void GetData(byte[] data);
public voidPassObject() {
IntPtr pbufer = Marshal.AlocHGlobal(1024);
byte[] bufer = (byte[])Marshal.PtrToStructure
(pbufer,typeof(byte[]);
GetData2(bufer);
UseData(bufer);
}
C.Reset Instructions Calculator.[DlImport("NativeLib.dl")]
public staticextern void GetData(IntPtr data);
-
8/22/2019 Exam 70-540
62/100
public voidPassObject() {
byte[] bufer = new byte[1024];
IntPtr p= Marshal.AlocHGlobal( Marshal.SizeOf (bufer);
Marshal.StructureToPtr(bufer,p,true);
GetData(p);
UseData(bufer);
Marshal.FreeHGlobal(p);
}
D.[DlImport("NativeLib.dl")]
public staticextern void GetData(byte[] data);
public voidPassObject() {
byte[] bufer = new byte[1024];
GetData(bufer);
UseData(bufer);
}
Question: 60
You arecreating a Microsoft Windows Mobilebased application.
You write the folowing code segment.
Microsoft.WindowsCE.Forms.Notification notify = newMicrosoft.WindowsCE.Forms.Notification();
You need to write the code segment that wil perform anaction whenthe notification bubble
appears.
Which code segment should you use?
A. notify.ResponseSubmited +=
newResponseSubmitedEventHandler(notify_ResponseSubmited);
B. notify.BaloonChanged +=
new BaloonChangedEventHandler(notify_BaloonChanged);
C.notify.Disposed+= new EventHandler(notify_Disposed);
-
8/22/2019 Exam 70-540
63/100
D.notify.InitialDuration = 0;
Question: 61
You arecreating a Microsoft Windows Mobilebased application.
The application mustalow users toview the e-mail addresses of their MicrosoftOfice Outlook
Mobile contacts througha user interface. You add a list box namedlstContacts to your Windows
Form.
You need to write the code segment to meet the requirement.
Which code segment should you use?
A. OutlookSessionoutlookSession = new OutlookSession();
foreach (Contact contact in outlookSession.Contacts.Items)
{ this.lstContacts.Items.Add(contact.Email1Address);
}
B. using(OutlookSessionoutlookSession = new OutlookSession()
{ foreach (Contactcontactin outlookSession.Contacts.Items)
{ this.lstContacts.Items.Add(contact.FileAs);
}
}
C.using (OutlookSession outlookSession = new OutlookSession() {
this.lstContacts.DataSource =outlookSession.Contacts.Items;
}
D.OutlookSession outlookSession= new OutlookSession();
foreach (Contact contact in outlookSession.Contacts.Items)
{ this.lstContacts.Items.Add(contact.ToString();
}
Question: 62
You arecreating a Microsoft Windows Mobilebased application. The application wil use an XML
Web service. The servicelocation is stored in a variable named new Server Address.
-
8/22/2019 Exam 70-540
64/100
You need to write the code segment that alows the applicationto retarget theXML Web service
location.
Which code segment should you use?
A. service.Proxy = newWebProxy(newServerAddress);
B. service.Url = newServerAddress;
C.service.AlowAutoRedirect = true;
D.service.UserAgent =newServerAddress;
Question: 63
You arecreating a Microsoft Windows Mobilebased application.
The application communicates with a remote server named data.contoso.com on port 80.
You needto send the message "Helo" to the remote server by using the TcpClient class.
Which code segment should you use?
A. TcpClient tcpClient= new TcpClient();
NetworkStream netStream = tcpClient.GetStream();
Byte[] sendBytes= Encoding.UTF8.GetBytes("Helo!");
netStream.Write(sendBytes, 0, 0);
tcpClient.Close();
netStream.Close();
B. TcpClient tcpClient= new TcpClient();
tcpClient.Connect("data.contoso.com", 80);
Socket socket= new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
NetworkStream netStream = new NetworkStream(socket);
Byte[] sendBytes= Encoding.UTF8.GetBytes("Helo!");
netStream.Write(sendBytes, 0, "Helo!".Length );
tcpClient.Close();
-
8/22/2019 Exam 70-540
65/100
netStream.Close();
C.TcpClient tcpClient = new TcpClient("data.contoso.com", 80);
tcpClient.Connect("data.contoso.com", 80);
NetworkStream netStream = tcpClient.GetStream();
Byte[] sendBytes= Encoding.UTF8.GetBytes("Helo!");
netStream.Write(sendBytes, 0,sendBytes.Length);
tcpClient.Close();
netStream.Close();
D.TcpClient tcpClient = new TcpClient("data.contoso.com", 80);
NetworkStream netStream = tcpClient.GetStream();
Byte[] sendBytes= Encoding.UTF8.GetBytes("Helo!");
netStream.Write(sendBytes, 0,sendBytes.Length);
tcpClient.Close();
netStream.Close();
Question: 64
You arecreating anapplication fora Microsoft Windows Mobilebased device.
The application communicates with theWindows Mobilebased device by using serial
communication.
The application sends Asian-language text to the Windows Mobilebased device.
You need to ensure that the text is transmited corectly by using the serial port.
Which code segment should you use?
A. SerialPortsp =new SerialPort("COM1");
sp.Encoding= Encoding.ASCI;
B. SerialPortsp =new SerialPort("COM1");
sp.Encoding= Encoding.Unicode;
C.SerialPort sp = new SerialPort("COM1");
D.SerialPort sp = new SerialPort("COM1");
-
8/22/2019 Exam 70-540
66/100
sp.Encoding = Encoding.UTF7;
Question: 65
You arecreating a Microsoft Windows Mobilebased application.
The application communicates with a Web site to retrieve a Webresponse.
You need to senda request to the Web serverasynchronously.
Which twoactions should you perform? (Each corect answer presents part of the solution.
Choose two.)
A. Get theHtpWebResponse objectby usingthe WebRequest.GetResponse() method.
B. Create theHtpWebRequest objectby using the WebRequest.Create() method thatpasses the
Web URLas a parameter.
C.Calthe HtpWebRequest.BeginGetResponse() method by passing aRespCalback as the
calbackdelegate.
D.Calthe HtpWebRequest.BeginGetRequestStream() method bypassinga
RespStreamCalback as the calback delegate.
Question: 66
You arecreating a Microsoft .NET CompactFramework application.Theapplication wil use an
XML Web service named GlobalMaps.
The GlobalMaps Web service contains the folowingmethod.
string GetCoordinates(string city);
The method provides the map coordinatesofspecific cities. The citiesare defined in thefolowing
class variable.
string[]cities =
{" New York ", "Chicago ", "Los Angeles ", "Portland "};
You write the folowing methodtodisplay the mapcoordinates of a specific city.
void ShowCoordinates(string city, string coords) {
.
-
8/22/2019 Exam 70-540
67/100
}
You need to write amethodnamed CalWebMethod that retrieves anddisplays the map
coordinates for each cityin the minimum amount of time.
Which code segment should you use?
A. void CalWebMethod(){
string coord;
GlobalMapsservice = new GlobalMaps();
foreach (string city in cities) {
coord = service.GetCoordinates(city);
ShowCoordinates(city,coord);
}
}
B. void CalWebMethod()
{ foreach (stringcity in cities)
{ string coord;
GlobalMapsservice = new GlobalMaps();
coord = service.GetCoordinates(city);
ShowCoordinates(city,coord);
}
}Reset InstructionsCalculator.
C.voidCalWebMethod() {
string coord;
GlobalMapsservice;
foreach (string city in cities) {
service =newGlobalMaps();
coord = service.GetCoordinates(city);
ShowCoordinates(city,coord);
}
}
-
8/22/2019 Exam 70-540
68/100
D.voidCalWebMethod() {
string coord;
foreach (string city in cities) {
coord = new GlobalMaps().GetCoordinates(city);
ShowCoordinates(city,coord);
}
}
Question: 67
You arecreating a Microsoft Windows Mobilebased application. The application accesses aWeb
site at www.contoso.com.
You write the folowing code segment.
try{
HtpWebRequestrequest;
request =
(HtpWebRequest)WebRequest.Create("htp:/www.contoso.com");
HtpWebResponse response =
(HtpWebResponse)request.GetResponse();
}
You need to detect any erors specific to the HtpWebRequest class. Youalsoneedto displaythe
erormessage,response status,and description informationfor theerors detected.
Which code segment should you use?
A. catch(WebException webException) {
string msg= "Message: " +webException.Message;
WebResponse response =
-
8/22/2019 Exam 70-540
69/100
(WebResponse)webException.Response;
msg += "\r\nStatusCode:" +response.Headers["StatusCode"];
msg += "\r\nDescription:" +
response.Headers["StatusDescription"];
MessageBox.Show(msg);
}
B. catch(WebException webException) {
string msg= "Message: " +webException.Message;
HtpWebResponse response =
( HtpWebResponse)webException.Response;
msg += "\r\nStatusCode:" +
(int)response.StatusCode).ToString();
msg += "\r\nDescription:" +response.StatusDescription;
MessageBox.Show(msg);
}Reset InstructionsCalculator.
C.catch (WebExceptionwebException)
{ HtpWebResponse response =
(HtpWebResponse)webException.Response;
string msg= "Message: " + response.Headers["Message"];
msg += "\r\nStatusCode:" +response.Headers["Status"];
msg += "\r\nDescription:" + response.Headers["Description"];
Mes sageBox.Show(msg);
}
D.catch {
WebException webException = newWebException("Web Exception");
string msg= "Message: " +webException.Message;
HtpWebResponse response =
(HtpWebResponse)webException.Response;
msg += "\r\nStatusCode:" +
(int)response.StatusCode).ToString();
-
8/22/2019 Exam 70-540
70/100
msg += "\r\nDescription:" +response.StatusDescription;
MessageBox.Show(msg);
}
Question: 68
You arecreating a Microsoft Windows Mobilebased application. The application wil use two
Microsoft SQL Mobile databases named Sales.sdf andLogData.sdf. Both thesedatabases must
beencrypted by using the password tempPass.
You write the folowing code segment.
string conStr= "DataSource =
'Sales.sdf'; Password = 'tempPass'";
SqlCeConnection connection =
New SqlCeConnection(conStr);
connection.Open();
.
You need to connect the application tothe LogData.sdfdatabaseby using the same
SqlCeConnection object.
Which code segment should you use?
A. connection.Close();
connection.ChangeDatabase("'LogData.sdf'");
connection.Open();
.
connection.Close();
B. connection.ChangeDatabase("'LogData.sdf'");
.
connection.Close();
C.connection.Close();
-
8/22/2019 Exam 70-540
71/100
conStr = "Data Source = 'LogData.sdf';Password ='tempPass'";
connection.ConnectionString = conStr;
connection.Open();
.
connection.Close();
D.conStr = "Data Source= 'LogData.sdf'; Password ='tempPass'";
connection.ConnectionString = conStr;
connection.GetSchema();
.
connection.Close();
Question: 69
You arecreating a Microsoft Windows Mobilebased application.
The application wil replicate datafrom a Microsoft SQL Server 2005 database intoa Microsoft
SQLMobile databasenamed MyData.sdf. The database MyData.sdf doesnot exist.
You create a SqlCeReplicationobject named rep.
You need to create MyData.sdf dynamicaly in the My Documents folder.
Which code segment should you use?
A. rep.SubscriberConnectionString = "Data Source =
\My Documents\MyData.sdf";
rep.AddSubscription(AddOption.ExistingDatabase);
B. rep.SubscriberConnectionString = "Data Source =
\My Documents\MyData.sdf";
rep.AddSubscription(AddOption.CreateDatabase);
C.rep.Subscriber = "\My Documents\MyData.sdf";
rep.AddSubscription(AddOption.ExistingDatabase);
D.rep.Subscriber = "\My Documents\MyData.sdf";
rep.AddSubscription(AddOption.CreateDatabase);
-
8/22/2019 Exam 70-540
72/100
Question: 70
You arecreating a Microsoft Windows Mobilebased application. You use a Microsoft SQL Server
databasethat has a tablenamed Customers. The Customers table contains acolumnnamed
CountryCode thatalows nul values. The defaultvalueofthe CountryCode column is set to USA.
You need to set the CountryCodetothe default value USA for althe records in theCustomers
table in which theCountryCode has a nulvalue.
Which SQL statement should you use?
A. UPDATE Customers SET CountryCode=DEFAULT WHERE CountryCode=NULL
B. UPDATE Customers SET CountryCode=DEFAULT WHERE CountryCode IS NULL C.
UPDATE Customers SET CountryCode='DEFAULT' WHERE CountryCode=NULL
D.UPDATE Customers SET CountryCode='DEFAULT'WHERECountryCode IS NULL
Question: 71
You arecreating a Microsoft Windows Mobilebased application.
The application connects to a MicrosoftSQL Mobiledatabase named SalesData.sdf.
You write the folowing code segment.
SqlCeConnection cnnSales =newSqlCeConnection("Data Source='SalesData.sdf'");
cnnSales.Open();
SqlCeTransaction tr =cnnSales.BeginTransaction();
.
try{
.
tr.Commit();
}
The application mightthrowanexception duringanupdate operation.
You need to rolback the transaction ifan exception occurs during the updateoperations. You
also need to close theSqlCeConnection object.
-
8/22/2019 Exam 70-540
73/100
Which code segment should you use?
A. catch(Exceptionexc){
tr.Rolback();
}
finaly {
cnnSales.Close();
}
B. catch(Exceptionexc)
{ tr.Rolback();
cnnSales.Close();
}
finaly {
}
C.catch (Exception exc) {
}
finaly
{ tr.Rolback();
cnnSales.Close();
}
D.catch (Exception exc) {
cnnSales.Close();
}
finaly {
tr.Rolback();
}
Question: 72
You arecreating a Microsoft Windows Mobilebased application. You connectthe application to a
-
8/22/2019 Exam 70-540
74/100
Microsoft SQL Mobile database by using a SqlCeConnectionobject.
The SqlCeConnection objectgenerates warningmessages during database operations.
You need to logal low severity warning messages thatare sentby theSqlCeConnection object.
What should you do?
A. Wrapal database activities byusing atryblock and use the folowing catch block.
catch (SqlCeExceptionexc) {
string message = exc.Message;
/Log message
}
B. Wrapal database activities byusing atryblock and use the folowing catch block.
catch (SqlCeExceptionexc) {
foreach (SqlCeEror er in exc.Erors) {
string message = er.Message;
/Log message