Free Cheat-test Samples and Demo Questions Download
Adobe exams Adobe
Apple exams Apple
Avaya exams Avaya
Check Point exams Check Point
Cisco exams Cisco
Citrix exams Citrix
CIW exams CIW
CompTIA exams CompTIA
CWNP exams CWNP
EC-Council exams EC-Council
EMC exams EMC
Exin exams Exin
Fortinet exams Fortinet
GIAC exams GIAC
Hitachi exams Hitachi
HP exams HP
IBM exams IBM
Isaca exams Isaca
ISC exams ISC
ISEB exams ISEB
Juniper exams Juniper
LPI exams LPI
McAfee exams McAfee
Microsoft exams Microsoft
Oracle exams Oracle
PMI exams PMI
Riverbed exams Riverbed
SNIA exams SAP
Sun exams SAS
Symantec exams Symantec
VMware exams VMware
All certification exams

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

Free 70-540(CSharp) Sample Questions:

1. You are creating a Microsoft Windows Mobilebased application.
The application stores real-time order information for small businesses. The number of orders ranges from a minimum of 0 to a maximum of 5000.
You need to ensure that the application achieves optimum performance for any number of orders within the specified range.
Which class should you choose?
A. OrderedDictionary
B. HybridDictionary
C. ListDictionary
D. Hashtable
Answer: B

2. You are creating a Microsoft Windows Mobilebased application. You are required to create custom data types that derive from a system type.
The system type must satisfy the following requirements:
Ensure the type safety of collections during compilation.
Improve the code readability of the application.
Minimize the potential for run-time errors.
You need to identify the system type that meets the outlined requirements.
Which system type should you choose?
A. Delegate type
B. Nullable type
C. Generic type
D. Value type
Answer: C

3. You are creating a Microsoft Windows Mobilebased application.
The application uses a custom exception class named MyException that transmits stack information. The MyException class is derived from the Exception class. The application contains a method named ThrowException.
You write the following code segment.
try { ThrowException(); }
The ThrowException method throws an exception of type MyException.
You need to rethrow the exception. You also need to preserve the stack information of previous exceptions.
Which code segment should you use?
A. catch ( MyException ex) {
throw new Exception( ex.Message );
}
B. finally {
throw new MyException();
}
C. catch {
throw;
}
D. catch (Exception ex) {
throw ex;
}
Answer: C

4. You are creating a Microsoft Windows Mobilebased application.
You create a class named InventoryManager. The InventoryManager class uses events to alert subscribers about changes in inventory levels.
You need to create delegates in the InventoryManager class to raise events to subscribers.
Which code segment should you use?
A. public event InventoryChangeEventHandler OnInventoryChange;
public delegate void InventoryChangeEventHandler (object source, EventArgs e);
B. private event InventoryChangeEventHandler OnInventoryChange;
private delegate void InventoryChangeEventHandler (object source, EventArgs e);
C. public event EventHandler OnInventoryChange;
public void InventoryChangeHandler(object source, EventArgs e) {
this.OnInventoryChange();
}
D. private event EventHandler OnInventoryChange;
private void InventoryChangeHandler(object source, EventArgs e) {
this.OnInventoryChange();
}
Answer: A

5. You are creating a Microsoft Windows Mobilebased inventory application.
The application must create reports that display inventory part numbers.
You need to write a method named WritePart that displays the part numbers in the following format:
A minimum of three digits to the left of the decimal point
Exactly two digits to the right of the decimal point
Left-aligned output
Which code segment should you use?
A. public static void WritePart(IFormattable t, CultureInfo ci) {
Console.WriteLine
("{0,-30}{1,30}", "Part:", t.ToString("000.00", ci));
}
B. public static void WritePart(IFormattable t, CultureInfo ci) {
Console.WriteLine
("{0,-30}{1,30}", "Part:", t.ToString("000.##", ci));
}
C. public static void WritePart(IFormattable t, CultureInfo ci) {
Console.WriteLine
("{0,30}{1,30}", "Part:", t.ToString("###.##", ci));
}
D. public static void WritePart(IFormattable t, CultureInfo ci) {
Console.WriteLine
("{0,30}{1,30}", "Part:", t.ToString("###.00", ci));
}
Answer: A

6. You are creating a Microsoft .NET Compact Framework application. The application uses a StringBuilder class to manipulate text. You write the following code segment.
StringBuilder sb = new StringBuilder(100);
After the code segment is executed, the text buffer of the StringBuilder class displays the following text:
Microsoft Corporation, Redmond, WA.
You need to write a code segment to clear the 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);
Answer: B

7. You are creating a Microsoft Windows Mobilebased application. The application will manage product inventory for retail stores. You are creating a class that will contain a method named Contains. The method will search for the items in the store. The items are of reference types and value types.
You need to identify the code that uses the minimum amount of execution time for both reference types and value types.
Which code segment should you use?
A. public bool Contains(T[] array, T value) {
for (int i = 0; i < array.Length; i++) {
if (EqualityComparer<T>.Default.Equals(array[i], value))
return true;
}
return false;
}
B. public bool Contains(T[] array, object value) {
for (int i = 0; i < array.Length; i++) {
if (array.GetValue(i).Equals(value))
return true;
}
return false;
}
C. public bool Contains(IEnumerable array, object value) {
foreach (object obj in array) {
if (obj.Equals(value))
return true;
}
return false;
}
D. public bool Contains(IEnumerable array, object value) {
foreach (object obj in array) {
if (obj == value)
return true;
}
return false;
}
Answer: A

8. You are creating a Microsoft Windows Mobilebased application.
You create a class named Employee. You also create an Executive class, a Manager class, and a
Programmer class. These three classes inherit from the Employee class.
You need to create a custom type-safe collection that manages only those classes that are derived from the Employee class.
Which code segment should you choose?
A. class EmployeeCollection < T > : List < T >
B. class Emp l oyeeCollection < T > : ICollection
C. class EmployeeCollection < T > : CollectionBase where T:class
D. class EmployeeCollection < T > : CollectionBase where T:Employee
Answer: D

9. You are creating a multithreaded Microsoft Windows Mobilebased application.
The application has two separate procedures. Each procedure must run on its own threads.
public void ThreadProc1() { }
public void ThreadProc2() { }
ThreadProc1 must complete execution before ThreadProc2 begins execution.
You need to write the code segment to run both procedures.
Which code segment should you use?
A. Thread thread1 = new Thread(new ThreadStart(ThreadProc1));
Thread thread2 = new Thread(new ThreadStart(ThreadProc2));
thread1.Start();
...
thread1.Join();
thread2.Start();
B. Thread thread1 = new Thread(new ThreadStart(ThreadProc1));
Thread thread2 = new Thread(new ThreadStart(ThreadProc2));
lock(thread1) {
thread1.Start();
...
}
thread2.Start();
C. Thread thread1 = new Thread(new ThreadStart(ThreadProc1));
Thread thread2 = new Thread(new ThreadStart(ThreadProc2));
thread1.Start();
...
Monitor.TryEnter(thread1);
thread2.Start();
Monitor.Exit(thread1);Reset Instructions Calculator
D. .Thread thread1 = new Thread(new ThreadStart(ThreadProc1));
Thread thread2 = new Thread(new ThreadStart(ThreadProc2));
thread1.Start();
...
Interlocked.Exchange(ref thread1, thread2);
thread2.Start();
Answer: A

10. You are creating a Microsoft .NET Compact Framework application. You write the following code
segment.
public class Target {
public void SetValue(int value) { }
}
You need to write a method named CallSetValue that calls the SetValue method by using late binding.
Which code segment should you use?
A. public void CallSetValue(int value) {
Target target = new Target();
MethodInfo mi = target.GetType().GetMethod("SetValue");
mi.Invoke(target, new object[] { value });
}
B. public void CallSetValue(int value) {
Target target = new Target();
MethodInfo mi = target.GetType().GetMethod("Target.SetValue");
mi.Invoke(target, new object[] { value });
}
C. public void CallSetValue(int value) {
Target target = new Target();
MethodInfo mi = target.GetType().GetMethod("Target.SetValue");
mi.Invoke(value, null);
}
D. public void CallSetValue(int value) {
Target target = new Target();
MethodInfo mi = target.GetType().GetMethod("SetValue");
mi.Invoke(value, null);
}
Answer: A

11. You are creating a Microsoft Windows Mobilebased application. The application contains a Windows Form that has a panel.
You need to ensure that the panel remains attached to the bottom of the Windows Form even when the screen size changes. At run time the user must be able to resize the panel by using a splitter control.
What should you do?
A. Set the Dock property of the panel equal to DockStyle.Bottom.
B. Set the Anchor property of the panel equal to AnchorStyles.Bottom.
C. Set the Height property of the panel equal to the Height property of the Windows Form.
D. Set the Control.Size property of the panel equal to the Control.Size property of the Windows Form.
Answer: A

12. You are creating a Microsoft Windows Mobilebased application. The application contains a Windows Form that has a text box control named TxtSalary. The application also contains a class named Employee that has a property named Salary.
You create an instance of the Employee class named emp in the Windows Form.
You need to write the code segment that binds TxtSalary to emp. You also need to ensure that the code segment displays the salary of an employee as a currency value prefixed by the currency symbol.
Which code segment should you use?
A. Binding bind = new Binding("Text", emp, "Salary");
bind.FormattingEnabled = true;
bind.FormatString = "C";
TxtSalary.DataBindings.Add(bind);
B. Binding bind = new Binding("Text", emp, "Salary");
bind.FormattingEnabled = true;
bind.FormatInfo = new NumberFormatInfo();
TxtSalary.DataBindings.Add(bind);
C. Binding bind = new Binding("Salary", emp, "Currency");
bind.FormattingEnabled = true;
bind.FormatInfo = new NumberFormatInfo();
TxtSalary.DataBindings.Add(bind);
D. Binding bind = new Binding("Salary", emp, "C");
bind.FormattingEnabled = true;
TxtSalary.DataBindings.Add(bind);
Answer: A

13. You are creating a Microsoft Windows Mobilebased application. The Windows Mobilebased application contains a Windows Form that has two text boxes.
You create KeyPressEventHandler delegates for the Windows Form and the two text boxes to handle the KeyPress events. The KeyPressEventHandler delegate for the Windows Form ensures that only letters or digits are entered. The KeyPressEventHandler delegate for the text boxes contains code that validates the letters or digits that are entered.
You need to ensure that the KeyPress events are handled appropriately.
Which two tasks should you perform? (Each correct answer presents part of the solution. Choose two.)
A. Set the KeyPreview property of the Windows Form to True.
B. Set the KeyPreview property of the Windows Form to False.
C. Set the Handled property of the KeyEventArgs object to True inside the KeyPressEventHandler method for the Windows Form if the entered character is neither a letter nor a digit.
D. Set the Handled property of the KeyEventArgs object to False inside the KeyPressEventHandler method for the Windows Form if the entered character is neither a letter nor a digit.
E. Set the Handled property of the KeyEventArgs object to False inside the KeyPressEventHandler method for the text boxes.
F. Set the Handled property of the KeyEventArgs object to True inside the KeyPressEventHandler method for the text boxes.
Answer: AC

14. You are creating a Microsoft Windows Mobile smartphonebased application. The application has a Windows Form. The form has a main menu control named MnuMain.
The form must contain two top-level menus named MnuOptions and MnuHelp. The MnuOptions menu must contain two submenus named MnuNew and MnuEdit.
The top-level menus must be activated by using the following soft keys:
Right soft key for the MnuOptions menu
Left soft key for the MnuHelp menu
You write the following code segment.
MenuItem MnuHelp = new MenuItem();
MenuItem MnuOptions = new MenuItem();
MenuItem MnuNew = new MenuItem();
MenuItem MnuEdit = new MenuItem();
You need to ensure that the menus meet the outlined requirements.
Which code segment should you use?
A. MnuOptions.MenuItems.Add(MnuNew);
MnuOptions.MenuItems.Add(MnuEdit);
MnuMain.MenuItems.Add(MnuOptions);
MnuMain.MenuItems.Add(MnuHelp);
B. MnuOptions.MenuItems.Add(MnuNew);
MnuOptions.MenuItems.Add(MnuEdit);
MnuMain.MenuItems.Add(MnuHelp);
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);
Answer: B

15. You are creating a Microsoft Windows Mobilebased application. You are creating a text box control named DigitBox that allows only numbers to be entered.
The classes that inherit from the DigitBox control must be able to allow characters other than numbers to be entered.
You need to write the correct class definition for the DigitBox control.
Which code segment should you use?
A. public class DigitBox : TextBox {
protected override void OnKeyPress(KeyPressEventArgs e) {
if (char.IsDigit(e.KeyChar) == false) e.Handled = true;
}
}
B. public class DigitBox : TextBox {
public DigitBox() {
this.KeyPress += new KeyPressEventHandler(DigitBox_KeyPress);
}
private void DigitBox_KeyPress(object sender,
KeyPressEventArgs e) {
if (char.IsDigit(e.KeyChar) == false) e.Handled = true;
}
}
C. public class DigitBox : TextBox {
protected override void OnKeyPress(KeyPressEventArgs e) {
if (char.IsDigit(e.KeyChar) == false) e.Handled = false;
}
}
D. public class DigitBox : TextBox {
public DigitBox() {
this.KeyPress += new KeyPressEventHandler(DigitBox_KeyPress);
}
private void DigitBox_KeyPress(object sender,
KeyPressEventArgs e) {
if (char.IsDigit(e.KeyChar) == false) e.Handled = false;
}
}
Answer: A

16. You are creating a Microsoft Windows Mobilebased application. The application contains a Windows Form. The form contains a panel that has constituent controls.
You need to design the panel such that it remains in the lower-left portion of the form.
What should you do?
A. Set the Anchor property of the panel to AnchorStyles.Left.
B. Set the Location property of the panel to the 0,0 position of the form.
C. Set the Anchor property of the panel to AnchorStyles.Left and AnchorStyles.Bottom.
D. Set the Location property of the panel to a horizontal point at position 0 and a vertical point to the height
of the form.
Answer: C

17. You are creating a Microsoft Windows Mobilebased application. The application contains a Windows Form and a class named CustomPanel. The form contains the following objects:
Two buttons named BtnNext and BtnFinish Ten Panel objects
Two CustomPanel objects named PreviousPanel and CurrentPanel
The PreviousPanel object refers to the previously displayed panel object. The CurrentPanel object refers to the currently displayed panel object.
The CustomPanel class contains two event handler methods named NextClick and FinishClick.
The application must allow a user to navigate to the next panel object in the form when the user clicks the BtnNext button.
You need to write the code segment for the click event of the BtnNext button to meet the following requirements:
Ensure that the click event of the BtnNext button invokes the NextClick method for the currently displayed CustomPanel object.
Ensure that the click event of the BtnFinish button invokes the FinishClick method for all the previously displayed CustomPanel objects.
Which code segment should you use?
A. BtnNext.Click += new EventHandler(CurrentPanel.NextClick);
BtnFinish.Click += new EventHandler(CurrentPanel.FinishClick);
B. BtnNext.Click += new EventHandler(CurrentPanel.NextClick);
BtnFinish.Click -= new EventHandler(PreviousPanel.FinishClick);
BtnFinish.Click += new EventHandler(CurrentPanel.FinishClick);
C. BtnNext.Click -= new EventHandler(PreviousPanel.NextClick);
BtnNext.Click += new EventHandler(CurrentPanel.NextClick);
BtnFinish.Click += new EventHandler(CurrentPanel.FinishClick);
D. BtnNext.Click -= new EventHandler(PreviousPanel.NextClick);
BtnNext.Click += new EventHandler(CurrentPanel.NextClick);
BtnFinish.Click -= new EventHandler(PreviousPanel.FinishClick);
BtnFinish.Click += new EventHandler(CurrentPanel.FinishClick);
Answer: C

18. You are creating a Microsoft Windows Mobilebased application.
The application contains aWindows Form that has the following code segment. (Line numbers are included for reference only.)
01 public delegate int UiUpdateDelegate();
02 private int LongRunningUiUpdate() {
03 ...
04 }
05 public void LongRunningWork() {
06
07 }
The application calls the LongRunningWork method from a different thread.
You need to call the LongRunningUiUpdate method from the LongRunningWork method asynchronously.
You also need to ensure that the code segment retrieves the value returned by the LongRunningUiUpdate method.
Which code segment should you insert at line 06?
A. UiUpdateDelegate del = new UiUpdateDelegate(LongRunningUiUpdate);
...
int value=(int)this.Invoke( del );
B. UiUpdateDelegate del = new UiUpdateDelegate(LongRunningUiUpdate);
IAsyncResult res = this.BeginInvoke( del );
...
int value = (int)this.EndInvoke(res);
C. UiUpdateDelegate del = new UiUpdateDelegate(LongRunningUiUpdate);
IAsyncResult res = this.BeginInvoke( del );
...
int value = (int)res.AsyncState;
D. UiUpdateDelegate del = new UiUpdateDelegate(LongRunningUiUpdate);
IAsyncResult res = this.BeginInvoke( del );
...
this.EndInvoke(res);
int value = (int)res.AsyncState;
Answer: B

19. You are creating a Microsoft Windows Mobilebased application that formats XML streams. You use the StringWriter class to receive XML streams.
You need to write a method named AppendNewLineToWriter that inserts new line characters at the end of the XML stream and returns the resulting string.
Which code segment should you use?
A. public string AppendNewLineToWriter(StringWriter sw ) {
string str = sw.ToString ();
return str.Insert ( sw.GetStringBuilder (). MaxCapacity - 1, "\r\n");
}
B. public string AppendNewLineToWriter(StringWriter sw ) {
return sw.NewLine = "\r\n";
}
C. public string AppendNewLineToWriter(StringWriter sw ) {
StringBuilder sb = sw.GetStringBuilder ();
return sb.Insert ( sb.Capacity , "\r\n").ToString();
}
D. public string AppendNewLineToWriter(StringWriter sw ) {
sw.WriteLine ();
return sw.ToString ();
}
Answer: D

20. You create a Microsoft .NET Compact Framework application for a Microsoft Windows Mobilebased device.
The application stores information in files that are stored in a folder on the file system of the Windows Mobilebased device.
You need to enumerate the files and subfolders within a specified path. You also need to set the Archive attribute and the Read Only attribute for each file and subfolder.
Which two code segments should you use? (Each correct answer presents part of the solution. Choose two.)
A. public void EnumerateContents(string path) {
DirectoryInfo folder = new DirectoryInfo(path);
foreach (DirectoryInfo subFolder in
folder.GetDirectories()) {
ProcessFileorFolder(subFolder);
}
foreach (FileInfo file in folder.GetFiles()) {
ProcessFileorFolder(file);
}
}
B. public void EnumerateContents(string path) {
DirectoryInfo folder = new DirectoryInfo(path);
foreach (DirectoryInfo subFolder in
folder.GetDirectories(\\)) {
ProcessFileorFolder(subFolder);
}
foreach (FileInfo file in folder.GetFiles()) {
ProcessFileorFolder(file);
}
}
C. public void ProcessFileorFolder(FileSystemInfo item) {
item.Attributes |= FileAttributes.Archive;
item.Attributes |= FileAttributes.ReadOnly;
}
D. Reset Instructions Calculator.public void ProcessFileorFolder(FileSystemInfo item) {
item.Attributes += FileAttributes.Archive;
item.Attributes += FileAttributes.ReadOnly;
}
Answer: AC


© 2014 Cheat-Test.com, All Rights Reserved