Exam 70-540
Exam 70-540
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?
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.
A. Delegate 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.
A. catch( MyExceptionex) { throw new Exception( ex.Message ); } B. finaly { throw new MyException(); } C.catch { throw;
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
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); }
Question: 6 You arecreating a Microsoft .NET Compact Framework application.Theapplication uses a StringBuilder class to manipulate text.
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.
A. public boolContains(T[]aray, T value) { for (int i = 0;i< aray.Length; i++) { if (EqualityComparer<T>.Default.Equals(aray[i], value) returntrue; } returnfalse; } B. public boolContains(T[]aray, object value) {
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
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 <T> :ColectionBase where T:class D.class EmployeeColection <T> :ColectionBase where T:Employee
The application has two separate procedures.Each procedure must runon its own threads. publicvoidThreadProc1() { } publicvoidThreadProc2() { } ThreadProc1 mustcomplete execution beforeThreadProc2 begins execution.
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){
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();
You need to write amethodnamed CalSetValue that calsthe SetValuemethodby usinglate binding.
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.
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;
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
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?
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;
} } 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.
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);
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.
A. UiUpdateDelegate del = new UiUpdateDelegate(LongRunningUiUpdate); . int value=(int)this.Invoke( del ); B. UiUpdateDelegate del = new UiUpdateDelegate(LongRunningUiUpdate); IAsyncResult res= this.BeginInvoke(del);
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();
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);
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.
publicForm1() { InitializeComponent(); this.Load +=newEventHandler(Form1_Load); this.Closing +=newCancelEventHandler(Form1_Closing); } void Form1_Load(object sender, EventArgs e)
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
diferent. You need to merge the documents intoa singleXML documentby usinga method of the XMLDocument class. Which method shouldyou use?
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);
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";
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 application relaysorder 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?
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 (); }
DataTableordersDataTable= new DataTable("Orders"); publicMainForm (){ InitializeComponent (); this.ordersDataTable.Columns.Add ("OrderID", typeof(int); this.ordersDataTable.Columns.Add ("Total", typeof(int); customerDataSet.Tables.Add ( ordersDataTable ); }
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.
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.
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); }
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.)
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
(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";
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?
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.
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.
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");
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.
SqlCeConnection cnn =new SqlCeConnection(); cnn.ConnectionString ="Data Source='Sales.sdf'"; cnn.Open(); SqlCeCommand cmd = new SqlCeCommand(); cmd.Connection= cnn; cmd.CommandText =
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);
You need to catch theexception that is thrown if the database file is unavailable.
A. catch(ArgumentException exc){ . } B. catch(IOException exc){ . } C.catch (SqlCeException exc) { . } D.catch (FileNotFoundException exc) { . }
Question: 36 You create a MicrosoftWindowsMobilebased application. You need to enable performance counters and logging for the application and log the information to a separate file.
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.
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.
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.
. } 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?
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?
" & 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;
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
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.
You need to retrievethe message from the local queue by extracting the Order classdata.
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.
Retrieve data from the Web service. Respond to user interactions while retrieving data.
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);
} 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); }
The application connects to a remote servernamed www.contoso.comonport 80. You need to retrievedata fromthe remote serverby usingthe TcpClient class.
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();
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();
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;
} 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.
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();
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.
typedef structDATA_STRUCT { DWORD id; WORD data1; WORD data2; } DATA_STRUCT; extern "C" __declspec(dlexport) voidGetData(DATA_STRUCT *pData);
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; }
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.
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 native definition forEnumWindows contains the folowing code segment. BOOL EnumWindows( WNDENUMPROC lpEnumFunc , LPARAMlParam ; )
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; }
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
Question: 54 You arecreating a Microsoft Windows Mobilebased application. The application must receive Windows messages from a nativeapplication.
You need to add code to the MsgWin class toensure that the applicationraises the MessageReceived event whena WM_APP message is received.
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);
} 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.
Microsoft.WindowsCE.Forms.Notification notify = new Microsoft.WindowsCE.Forms.Notification(); string text = "<html><body><form method='GET'action=notify>"; text+= "<SELECT NAME='list'>"; text += "<OPTION VALUE='0'>Start now</OPTION>"; text += "<OPTION VALUE='1'>Postpone</OPTION>"; text+= "</SELECT>"; text+= "<input type=submit >";
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.
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(); }
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.
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);
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, ref COPYDATASTRUCT 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;
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"); } }
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
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);
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 = new Microsoft.WindowsCE.Forms.Notification(); You need to write the code segment that wil perform anaction whenthe notification bubble appears. Which code segment should you use?
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.
You need to write the code segment that alows the applicationto retarget theXML Web service location. Which code segment should you use?
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();
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");
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) { .
} 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); } }
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 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?
(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();
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?
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);
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.
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
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 } } C.Create the folowingmethodthat handlesthe InfoMessage eventofthe SqlCeConnection object.void cnn_InfoMessage(object sender, SqlCeInfoMessageEventArgs e) { string message = e.Message; /Log message } D.Create the folowingmethodthat handlesthe InfoMessage eventofthe SqlCeConnection object.void cnn_InfoMessage(object sender, SqlCeInfoMessageEventArgs e) { foreach (SqlCeEror er in e.Erors) { string message = er.Message; /Log message } }
Question: 73 You arecreating a Microsoft Windows Mobilebased application. The application usesdata froma Microsoft SQL Server 2005 database named SalesData. Thisdatabase exists ona server named Accounts.
The application puls data from the SalesData database to a Microsoft SQLServer 2005 Compact Edition database named SalesLocal.sdf. The SalesDatadatabasehas astored procedure named SpEodRoutine. You create a SqlCeRemoteDataAccess object named rda. You need to write the code segment that executesthe stored procedure. Which code segment should you use?
A. rda.LocalConnectionString= "DataSource = ' SalesLocal.sdf '"; rda.Push(" SpEodRoutine ", "Data Source = Accounts;InitialCatalog = SalesData "); B. rda.LocalConnectionString= "Data Source = Accounts;InitialCatalog = SalesData "; rda.Push (" SpEodRoutine","Data Source= ' SalesLocal.sdf '"); C.rda.LocalConnectionString = "Data Source = Accounts;InitialCatalog = SalesData "; rda.SubmitSql (" SpEodRoutine ", "DataSource = 'SalesLocal.sdf '"); D.rda.LocalConnectionString = "Data Source = 'SalesLocal.sdf '"; rda.SubmitSql (" SpEodRoutine ", "DataSource = Accounts;InitialCatalog = SalesD ata ");
Question: 74 You create a Microsoft .NET Compact Frameworkapplication for a Microsoft Windows Mobilebased smartphonedevice. The application mustmeetthe folowing requirements:
It mustnot haveful access to the system APIs on the Windows Mobile-based device. It mustrun in the trusted mode. You need to ensure that the application meets the outlined requirements. Which sequence of three actions shouldyou perform? (To answer,move theappropriate three actions from the list ofactions to the answer areaand arange them inthe corectorder.)
Question: 75 You create a Microsoft .NET Compact Frameworkapplication. To deploy the application, you create a SmartDevice CAB project. You need to add a registrykey named MyAPP in theHKEY_LOCAL_MACHINE hive whenthe CAB fileisinstaled on theMicrosoft Windows Mobilebased device. What should you do?
A. In the Smart DeviceCAB project, open the File System Editor. Add afolder named HKEY_LOCAL_MACHINEtothe Program Files folder, and then add a registrykey named MyAPP. B. Modify the INF file and add the registry key by usingthe folowing line of text: "HKLM","MyApp",","0x00000000"," C.Create aRegistry.txt file by using the folowing lineoftext: "HKLM","MyApp",","0x00000000"," Add this file to the Smart DeviceCAB project. D.Inthe Smart Device CAB project, open theRegistry Editor,and then adda new key named MyAppin the HKEY_LOCAL_MACHINE folder.
Question: 76 You arecreating anapplication fora Microsoft Windows Mobilebased device. The application has a variable named builder of type StringBuilder. You executethe application in debugmode. You need to write the message "Not assigned" tothe Output window if builderisnul.You also need to ensure thatthe restofthe code is notexecuted when builder is nul. Which code segment should you use?
A. Debug.WriteIf (builder == nul, "Not assigned", "Eror"); B. Debug.WriteIf (builder != nul, "Not assigned", "Eror"); C.Debug.Assert (builder == nul, "Not assigned"); D.Debug.Assert (builder != nul, "Not assigned");
Question: 77 You arecreating a Microsoft Windows Mobilebased application. The application contains a functionnamed Calculate(). Whenyou test the applicationin a Microsoft Windows Mobile 5.0 emulator, the DivideByZeroException exceptionisthrown. You decide to debugthe application. You need to seta breakpoint on the Calculate() function. What should you do?
A. Modify the Calculate() function and adda Debugger.Break() statement. B. Click any lineofcode thatcals the Calculate() function and click ToggleBreakpoint. C.Open theBreakpoints window and click New-Function Breakpoint. Type Calculate() forthe function. D.Modify the Calculate()function and add aMessageBox.Show()statement. Pause the debugging sessionwhen the applicationdisplays the message box.
Question: 78 You arecreating a Microsoft Windows Mobilebased application. The application has a Windows Form named FrmProcess.TheFrmProcess form contains a butonnamed BtnProcess and a labelnamed LblStatusMsg.
The application mustexecute a long-running process. You write thefolowing codesegment. publicclass MyThreadClass { FrmProcess form;
Inside the FrmProcessclass,youwritethe folowing code segment. publicvoidUpdateStatusMsg (objectsender,EventArgsargs) { LblStatusMsg.Text = "Completed"; } privatevoidBtnProcess_Click(objectsender,EventArgse) { MyThreadClass process = new MyThreadClass(this); Thread thread = new Thread(new ThreadStart(process.LongRunningProcess); thread.Start(); }
You need to display the status messageonthe LblStatusMsg label after the thread finishes execution.
A. In the FrmProcessform, add the folowing code segment. publicEventHandler handler; publicFrmProcess() { .
handler = new EventHandler(UpdateStatusMsg); } B. In the FrmProcessform, add the folowing code segment. public event EventHandler handler; publicFrmProcess() { . handler+=newEventHandler(UpdateStatusMsg); } publicvoidOnEvent() { handler(this, EventArgs.Empty); } C.At the end of theLongRunningProcess method,insidethe MyThreadClass class, write the folowing code segment. form.OnEvent(); D.At the end of theLongRunningProcess method,insidethe MyThreadClass class, write the folowing code segment. form.handler.Invoke(form, EventArgs.Empty); E. At the end of the LongRunningProcess method, inside the MyThreadClass class,writethe folowing codesegment.form.Invoke(form.handler);
Question: 79 You arecreating a Microsoft Windows Mobilebased application. The application contains a Windows Form. You need to scalethe WindowsFormand alits controls to match a screen thathas9696dpi resolution. Which code segment should you use?
this.AutoScaleMode = AutoScaleMode.Dpi ; this.PerformAutoScale (); } B. SizeFs = new SizeF (96f, 96f); if (this.AutoScaleFactor == s) { SizeF s1 = new SizeF (120f, 120f); this.AutoScaleDimensions= s1; this.AutoScaleMode = AutoScaleMode.Dpi ; this.PerformAutoScale (); } C.SizeF s= new SizeF(1.0f, 1.0f); if (this.AutoScaleFactor != s) { SizeF s1 = new SizeF (96f, 96f); this.AutoScaleDimensions= s1; this.AutoScaleMode = AutoScaleMode.Inherit; this.PerformAutoScale (); } D.if ( this.CurentAutoScaleDimensions == this.AutoScaleDimensions ) { SizeF s = newSizeF (96f,96f); this.AutoScaleDimensions = s; this.AutoScaleMode = AutoScaleMode.Inherit; this.PerformAutoScale (); } Question: 80 You arecreating a Microsoft Windows Mobilebased application. The application hasa login form. The loginform contains twotextboxes named TxtUserName and TxtPassword and aMainMenu control namedMnuMain. The MnuMain control contains a MenuItem object named MnuEdit. The MnuEdit objectcontainsMenuItem objects. The application mustmeetthe folowing requirements:
When focus is in the TxtPassword text box, al menu items within MnuEdit must be disabled. Whenfocus is in the TxtUserName text box, al menu itemswithin MnuEdit must be enabled. You need to ensure that the application meets the outlined requirements. What should you do?
A. Write the folowing codesegmentin the Popupeventof the MnuEdit object. foreach (MenuItem mnuin MnuMain.MenuItems) { if(mnu.Parent==MnuEdit) mnu.Enabled = !TxtPassword.Focused; } B. Write the folowing codesegmentin the Popupeventof the MnuEdit object. foreach (MenuItem mnuin MnuEdit.MenuItems) { mnu.Enabled = !TxtPassword.Focused; } C.Writethe folowing code segmentin the GotFocus event of the TxtPassword text box. foreach (MenuItem mnuin MnuMain.MenuItems) { if (mnu.Parent ==MnuEdit) mnu.Enabled = !TxtPassword.Focused; } D.Writethe folowing code segmentin the GotFocus event of the TxtPassword text box. foreach (MenuItem mnuin MnuEdit.MenuItems) { mnu.Enabled = !TxtPassword.Focused; }.
Question: 81 You arecreating a Microsoft Windows Mobilebased application. You create a user controlnamed Login. The user controlhas two Butonobjects named BtnOkand BtnCancel. You need to alow users to set the BackColor property of boththe butons to a single color only. What should you do?
A. Change the Modifier property of the BtnOkand BtnCancel objects to public. B. Change the access modifier of the BackColorproperty of the Login control to protected. C. Write thefolowing code inside the Login user control. public Color ButonBackColor { get { return BtnOk.BackColor; } set { BtnOk.BackColor = value; BtnCancel.BackColor = value; } } D.Writethe folowing code inside the Login user control. publicColor BtnOkBackColor { get { return BtnOk.BackColor;} set { BtnOk.BackColor = value; } } publicColor BtnCancelBackColor { get { return BtnCancel.BackColor; } set { BtnCancel.BackColor= value;} }
Question: 82 You arecreating a Microsoft Windows Mobilebased application. The application contains a Windows Form. The form hasa panel named PnlMain and anInputPanel control named SipPanel. The PnlMain panel contains twotext boxes. Whenthe focus is onanyofthe text boxes, the SipPanel control is displayed. You need to ensure that the PnlMainpanel fils only the areaof theform that is not covered by the SipPanel control. Which code segment should you use?
A. public void SipPanel_EnabledChanged(object sender, EventArgs e) { if (SipPanel.Enabled) PnlMain.Height = this.height - SipPanel.VisibleDesktop.Height; else PnlMain.Height = this.height; } B. public void SipPanel_EnabledChanged(object sender, EventArgs e) { PnlMain.Height = SipPanel.VisibleDesktop.Height; } C.public void SipPanel_EnabledChanged(object sender, EventArgs e) { PnlMain.Height = SipPanel.Bounds.Height; } D.public void SipPanel_EnabledChanged(object sender, EventArgs e) { if (SipPanel.Enabled) PnlMain.Height = SipPanel.VisibleDesktop.Height SipPanel.Bounds.Height; else PnlMain.Height = SipPanel.VisibleDesktop.Height; }
Question: 83 You arecreating a Microsoft Windows Mobile-based application. The application contains a Windows Form. You need to ensure that the layout for the WindowsFormisset to Landscape atrun time. What should you do?
A. Set the AutoScaleMode property of the main form to AutoScaleMode.None. B. Set theMicrosoft.WindowsCE.Forms.ScreenOrientationproperty to Angle180. C. Setthe Microsoft.WindowsCE.Forms.ScreenOrientation property toAngle90.
Question: 84 You arecreating a Microsoft Windows Mobilebased application. The application has a class named Employee. The Employee class has a property namedName. You create an instanceof the Employeeclass namedemployee. You need to bind theName property ofthe Employeeclass to atext box namedTxtName. You also need to ensure thatthe name of the employee object is updated whenever the valuein the textboxischanged.
A. Binding binding =new Binding("Text", employee, "Name"); binding.ControlUpdateMode = ControlUpdateMode.OnPropertyChanged; TxtName.DataBindings.Add(binding); B. Binding binding =new Binding("Text", employee, "Name"); binding.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged; TxtName.DataBindings.Add(binding); C.Bindingbinding= new Binding("Name", employee, "Employee"); binding.DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged; TxtName.DataBindings.Add(binding); D.Bindingbinding= new Binding("Name", employee, "Employee"); binding.ControlUpdateMode = ControlUpdateMode.OnPropertyChanged;
TxtName.DataBindings.Add(binding);
Question: 85 You arecreating a Microsoft Windows Mobilebased application. The application usesgeneric colections to manage employee data.
You write the folowing code segment to create a genericclass named Employee<T>. publicclass Employee<T> { publicbool NameTest() { Ttemp = new T(); returntemp.Contains("John"); } }
You need to modifythe Employeeclass to accept only thosedata types that support the NameTestmethod.
Which twoactions should you perform? (Each corect answer presents part of the solution. Choose two.) A. SpecifyIList<class>as a constraint forT. B. Specify IList<string> asa constraint forT. C. Specify IComparable as a constraint for T. D.Specify new() as constraint forT.
Question: 86 You arecreating a Microsoft Windows Mobilebased application. You write the folowing code segment.
A. Addthe folowing code segment to the class. ~BitMapHelper() { customBitmap.Dispose(); customBitmap= nul; } B. ImplementIDisposable and add the folowingcode segment to theclass. publicvoidDispose() { customBitmap.Dispose(); customBitmap=nul; } ~BitMapHelper() { customBitmap.Dispose(); customBitmap= nul; } C..Implement IDisposableand add the folowing code segment to the class. publicvoidDispose() { GC.SuppressFinalize(this); }
~BitMapHelper() { customBitmap.Dispose(); customBitmap= nul; } D.Implement IDisposable and addthe folowing code segment to the class. publicvoidDispose() { customBitmap.Dispose(); customBitmap=nul; }
Question: 87 You arecreating a Microsoft Windows Mobilebased application. The application managesa colection of employee names by using an object namedarEmployees of typeArayList. You need to sort only thefirst 10 employee names indescending order. Which twocode segments should you use? (Each corect answer presents part of the solution. Choose two.)
A. public class DescComparer:System.Colections.IComparer { public int Compare(objectx, objecty){ returnx.ToString (). CompareTo(y); } } B. public class DescComparer :System.Colections.IComparer{ public int Compare(objectx, objecty){ returny.ToString (). CompareTo(x); } } C.arEmployees.Sort (0, 10, new DescComparer (); D. arEmployees.Sort (10, 0, new DescComparer ();
Question: 88 You areworkingona multithreaded Microsoft .NET Compact Framework application.The application creates threads in aThreadPool class.Thethreadprocedure mustoccasionaly increment aclass-scoped variable. You need to create an appropriate implementationto update the variable. Which three code segments shouldyouchoose? (Each corect answer presents a complete solution. Choose three.)
A. private int m_sharedData = 0; private void WorkerThreadProc() { Interlocked.Increment(refm_sharedData); } B. private int m_sharedData = 0; private void WorkerThreadProc() { m_sharedData++; } C.private intm_sharedData = 0; private void WorkerThreadProc() { lock(this) { m_sharedData++; } } D.private intm_sharedData = 0; private void WorkerThreadProc() {Monitor.Enter(this); m_sharedData++; Monitor.Exit(this);
} E. private int m_sharedData = 0; private void WorkerThreadProc() { Mutex m = newMutex(); m.WaitOne(); m_sharedData++; }
Question: 89 You arecreating a Microsoft Windows Mobilebased application. The application contains the definitionof a classnamed Publisher. The Publisher classmust meet thefolowing requirements: Publish eventstosubscribers. Use an event argument foralits eventmethods. Theeventargumentmust be an instanceof the CustomEventArgs class. You need to modifythe Publisher class to meet the outlined requirements. Which twocode segments should you use? (Each corect answer presents part of the solution. Choose two.)
A. public event EventHandler< CustomEventArgs > RaiseCustomEvent ;B. protected virtualvoidOnRaiseCustomEvent ( CustomEventArgs e) { if (RaiseCustomEvent != nul) RaiseCustomEvent (this, e); } C.protected virtual void OnRaiseCustomEvent () { RaiseCustomEvent (new CustomEventArgs(),EventArgs.Empty); } D.public eventEventHandler RaiseCustomEvent ;
Question: 90
You arecreating a Microsoft Windows Mobilebased application. The system consists of two independent class libraries named AssemblyA andAssemblyB. The two classlibraries provide data types thatare used by more than one application.You movethe Employee data type fromAssemblyA to AssemblyB. You need to redeploythe modified class libraries. You want to achievethis goalwithout breaking compatibility with existing applications that usethe old class libraries. Which twoactions should you perform? (Each corect answer presents part of the solution. Choose two.)
A. Adda reference to AssemblyB fromAssemblyA. B. Replace the Employee data type definition inAssemblyA byusing [assembly: TypeForwardedTo( typeof( Employee) )]. C.Ensure that the Employee data type is ina diferent namespace in AssemblyBthan in AssemblyA. D.Replace theEmployee data typedefinitionin AssemblyA by using [Obsolete("Employee has beenmoved toAssemblyB.")] E. Throwan exception named TypeLoadException when existing applications atempt to instantiate an Employee data type in AssemblyA.
Question: 91 You aremodifying a MicrosoftWindows Mobilebased retailapplication. The application uses events to communicatechanges ininventory levels. Any changein inventory level generatescustom eventdata. You need to pass the custom event data to the event handlers without breaking the existing code. What should you do?
A. Usethe EventArgs baseclass as aparameter to theevent handlers. B. Addadditional parameters for thecustom eventdata to theevent handlers. C.Overload theevent handlers to accept the custom event data asparameters.
D.Use a class derived from theEventArgsbase classas a parameter to the event handlers.
Question: 92
You arewriting a class library for aMicrosoft Windows Mobilebasedapplication. The class library isinstaled inthe global assemblycache. You must identify the path to the consuming application at run time. You need to retrievethe applicationpath as aString object. Which code segment should you use?
A. Application.StartupPath; B. Path.GetDirectoryName ( System.Reflection.Assembly.GetExecutingAssembly ( ). GetName (). CodeBase ); C.Path.GetDirectoryName( System.Reflection.Assembly.GetCalingAssembly ( ). GetName (). CodeBase ); D.(string)Microsoft.Win32.Registry.LocalMachine.GetValue( @"Software\Microsoft\.NET Compact Framework\" + @"Assemblies\ MyAssembly ");
Question: 93 You arecreating a Microsoft Windows Mobilebased applicationnamed MyApp. The application wil be instaled at the location \Program Files\MyApplication onthe Microsoft Windows Mobilebased devices.Whenexecuted,the application wilcreate afile named UserInput.txt. The UserInput.txt file mustbe saved at thesame location asMyApp. You write the folowing code segment. string fileName = "UserInput.txt"; string path = @"\Program Files\MyApplication\MyApp.exe"; You need to generatethe path ofthe UserInput.txtfile byusing the Path class.
A. path = Path.GetPathRoot(path); path = Path.Combine(path, fileName); B. path = Path.GetDirectoryName(path); path = Path.Combine(path, fileName); C.path = Path.GetFulPath(path); path =path + fileName; D.path = Path.Combine(path, fileName);
Question: 94 You arecreating anapplication for a Microsoft WindowsMobilebased device. The application logs diagnostic eventdata to a text file on the device. You need to ensure that the application logs al eventdata to thetext file without any dataloss. You also need to release al resources properly. Which method shouldyou cal?
A. The Close method of the BaseStream property of the StreamWriter class B. The Flush method of the BaseStream property of the StreamWriter class C.TheFlush method of theStreamWriter class D.TheClose method of theStreamWriter class
Question: 95
The application mustmeetthe folowing requirements: Encrypt the data it colects. Save the data to an XMLfile.
Which twoclassesshould youuse? (Each corect answer presents part of the solution. Choose two.)
The application contains an XML file named Orders.xml that has the folowing XML code. <?xml version="1.0" encoding="utf-8" ?> <!-Start colection of orders-> <orders> <!-Start order 1-> <orderID="1"> <!-Start line items for order 1-> <lineItems> <!-Start individual lineitems-> <lineItem productID="100">Item 100</lineItem> <lineItem productID="200">Item 200</lineItem> </lineItems> </order> <!-Start order 2-> <orderID="2">
<!-Start line items for order 2-> <lineItems> <!-Start individual lineitems-> <lineItem productID="300">Item 300</lineItem> <lineItem productID="400">Item 400</lineItem> </lineItems> </order> </orders> You write the folowing code segment. string path = Path.Combine(Path.GetDirectoryName ( System.Reflection.Assembly.GetExecutingAssembly( ).GetName().CodeBase), "Orders.xml");
A. XmlTextReader xmlTextReader = new XmlTextReader("file:/" + path); xmlTextReader.MoveToContent(); while (xmlTextReader.Read(){ if (xmlTextReader.NodeType != XmlNodeType.Comment) { if (xmlTextReader.HasAtributes) { string orderID =xmlTextReader.GetAtribute("ID"); } } } B. XmlTextReader xmlTextReader = new XmlTextReader("file:/" + path); xmlTextReader.MoveToContent();
while (xmlTextReader.Read(){ if (!xmlTextReader.Value.StartsWith("<!-"){ if (xmlTextReader.HasAtributes) { string orderID =xmlTextReader.GetAtribute("id"); } } } C.XmlTextReader xmlTextReader = new XmlTextReader(path); xmlTextReader.MoveToContent(); while (xmlTextReader.Read(){ if (!xmlTextReader.Name.StartsWith("<!-"){ if (xmlTextReader.HasAtributes) { string orderID =xmlTextReader.GetAtribute("ID"); } } } D.XmlTextReader xmlTextReader = new XmlTextReader(path); xmlTextReader.MoveToContent(); while (xmlTextReader.Read(){ if (xmlTextReader.NodeType != XmlNodeType.Comment) { if (xmlTextReader.HasAtributes) { string orderID =xmlTextReader.GetAtribute("id"); } } }
The application uses an XML file named Books.xml thathas the folowingXML code. <books> <book genre='novel' ISBN='1-861003-78' pubdate='2001'> <description>Description 1</description> </book> <book genre='biography' ISBN='1-861003-79' pubdate='2003'> <description>Description 2</description> </book> </books> You write the folowing code segment. string path = Path.GetDirectoryName (System.Reflection.Assembly.GetExecutingAssembly(). GetName().CodeBase);
You need to retrieve the values of theatribute ISBNfrom the Books.xml file.
A. XmlTextReader xmlTextReader = new XmlTextReader("file:/" + Path.Combine(path, "Books.xml"); while (xmlTextReader.MoveToContent() != XmlNodeType.None){ string isbn =xmlTextReader.GetAtribute("ISBN"); } B. XmlTextReader xmlTextReader = new XmlTextReader("file:/" + Path.Combine(path, "Books.xml"); xmlTextReader.MoveToContent(); while (xmlTextReader.Read(){ if (xmlTextReader.Name== "book" && xmlTextReader.NodeType ==XmlNodeType.Element) { string isbn =xmlTextReader.GetAtribute("ISBN");
} } C.XmlTextReader xmlTextReader = new XmlTextReader("file:/" + Path.Combine(path, "Books.xml"); xmlTextReader.MoveToContent(); while (xmlTextReader.Read(){ if (xmlTextReader.Name== "book" && xmlTextReader.NodeType ==XmlNodeType.Atribute) { string isbn =xmlTextReader.GetAtribute("ISBN"); } } D.XmlTextReader xmlTextReader = new XmlTextReader("file:/"+ Path.Combine(path, "Books.xml"); xmlTextReader.MoveToContent(); while (xmlTextReader.Read(){ if (xmlTextReader.Name== "book" && xmlTextReader.NodeType ==XmlNodeType.Element) { string isbn =xmlTextReader.GetAtribute(2); } }
Question: 98 You arecreating anapplication fora Microsoft WindowsMobilebased device. In the application, youwritethe folowing code segment. (Line numbersare includedfor reference only.)
01FileStreamfs = new FileStream (path, FileMode.Open , FileAccess.Write ); 02byte[] ByteAray= new byte[32]; 03fs.Read ( ByteAray, 0, 32);
Whenyou execute the code, a NotSupportedException exception is thrown. You need to modifythe code segment to avoidthe exception. What should you do?
A. Insert the folowing code segment between lines 01 and 02. fs.Position= 0; B. Replace line 01with the folowing code segment. FileStream fs = new FileStream (path, FileMode.OpenOrCreate , FileAccess.Write); C.Replace line 01 with the folowing code segment. FileStream fs = new FileStream (path, FileMode.Open , FileAccess.Read ); D.Replace line 03 with the folowing code segment. fs.Read ( ByteAray , 32, 32);
Question: 99 You arecreating anapplication for a Microsoft WindowsMobilebased device. You write the folowing code segment. DataSetds =newDataSet(); DataTablecustTable= new DataTable("Customer"); custTable.Columns.Add("CustomerID", typeof(Int32); DataTableprodTable = new DataTable("Product"); prodTable.Columns.Add("ProductID",typeof(Int32); DataTableordTable= new DataTable("Order"); ordTable.Columns.Add("CustomerID", typeof(Int32); ordTable.Columns.Add("ProductID", typeof(Int32); ds.Tables.Add(custTable); ds.Tables.Add(prodTable); ds.Tables.Add(ordTable);
The DataSetobject must meet the folowing requirements: Orders can beadded only for a valid customer. Orders can beadded only for a valid product. A CustomerID inthe Customer table that has orders cannot be deleted. A ProductID in theProducttable that has orders cannot be deleted. You need to configure the DataSet object to meet the outlined requirements. Which twocode segments should you use? (Each corect answer presents part of the solution. Choose two.)
A. DataColumn parentColumn = ds.Tables["Customer"].Columns["CustomerID"]; DataColumn childColumn = ds.Tables["Order"].Columns["CustomerID"]; ds.Relations.Add(newDataRelation("CustomerOrder", parentColumn, childColumn); B. .DataColumn parentColumn= ds.Tables["Order"].Columns["CustomerID"]; DataColumn childColumn = ds.Tables["Customer"].Columns["CustomerID"]; ds.Relations.Add(newDataRelation("CustomerOrder", parentColumn, childColumn); C.DataColumnparentColumn = ds.Tables["Order"].Columns["ProductID"]; DataColumn childColumn = ds.Tables["Product"].Columns["ProductID"]; ds.Relations.Add(newDataRelation("ProductOrder", parentColumn, childColumn); D.DataColumnparentColumn = ds.Tables["Product"].Columns["ProductID"]; DataColumn childColumn =
ds.Tables["Order"].Columns["ProductID"];
ds.Relations.Add(newDataRelation("ProductOrder", parentColumn, childColumn); E. DataColumn parentColumn = ds.Tables["Product"].Columns["ProductID"]; DataColumn childColumn = ds.Tables["Customer"].Columns["CustomerID"]; ds.Relations.Add(newDataRelation("CustomerProduct", parentColumn, childColumn);