Labels

Friday, August 27, 2010

#1 Practice test questions for Certification Exam 70-536‏

QUESTIONS Technology Focus: Developing applications that use system types and collections
1. You are developing a text processing application by using the .NET Framework. You write the following code to iterate over a collection of strings and populate a ListBox control with the values it contains (line numbers are for reference only). The GetStrings function returns an array of strings.
C#
01: StringCollection myStrCol = new StringCollection();
02: myStrCol.AddRange(GetStrings());
03: StringEnumerator myEnumerator = myStrCol.GetEnumerator();

Visual Basic
01: Dim myStrCol As StringCollection = New StringCollection()
02: myStrCol.AddRange(GetStrings())
03: Dim myEnumerator As StringEnumerator = myStrCol.GetEnumerator()
You need to add code to populate the ListBox control. What code should you add?
Option A

C#
while (myEnumerator.MoveNext())
      lstStrings.Items.Add(myEnumerator.Current);

Visual Basic
While (myEnumerator.MoveNext())
   lstStrings.Items.Add(myEnumerator.Current)
End While
Option B

C#
do
{
   lstStrings.items.Add(myEnumerator.Current)
} while (myEnumerator.MoveNext())

Visual Basic
Do
   lstStrings.items.Add(myEnumerator.Current)
Loop While (myEnumerator.MoveNext())
Option C

C#
myEnumerator.Reset();
do
{
   lstStrings.items.Add(myEnumerator.Current)
} while (myEnumerator.MoveNext())

Visual Basic
myEnumerator.Reset()
Do
   lstStrings.items.Add(myEnumerator.Current)
Loop While (myEnumerator.MoveNext())
Option D

C#
do
{
   lstStrings.items.Add(myEnumerator.Current)
   myEnumerator.Reset();
} while (myEnumerator.MoveNext())

Visual Basic
myEnumerator.Reset()
Do
   lstStrings.items.Add(myEnumerator.Current)
Loop Until (myEnumerator.MoveNext())

2. You are developing a .NET Framework application that uses the Stack class. You need to write code that enumerates through the stack.Your code must guarantee thread safety during the enumeration. Which code segment should you use?
Option A

C#
Stack myStack = new Stack();
lock (myStack.SyncRoot)
{
    foreach (Object item in myStack)
    {
        // additional code for processing.
    }
}

Visual Basic
Dim myStack As Stack = New Stack()
SyncLock myStack.SyncRoot
    For Each item As Object In myStack
        ' additional code for processing.
    Next
End SyncLock
Option B

C#
Stack myStack = new Stack();
Stack syncStack = Stack.Synchronized(myStack);
foreach (Object item in syncStack)
{
   // additional code for processing.
}

Visual Basic
Dim myStack As Stack = New Stack()
Dim syncStack As Stack = Stack.Synchronized(myStack)
For Each item As Object In syncStack
    ' additional code for processing.
Next
Option C

C#
Stack myStack = new Stack();
Stack syncStack = (Stack) myStack.SyncRoot;
foreach (Object item in syncStack)
{
    // additional code for processing.
}

Visual Basic
Dim myStack As Stack = New Stack()
Dim syncStack As Stack = myStack.SyncRoot
For Each item As Object In syncStack
    ' additional code for processing.
Next
Option D

C#
Stack myStack = new Stack();
lock (Stack.Synchronized(myStack))
{
    foreach (Object item in myStack)
    {
        // additional code for processing.
    }
}

Visual Basic
Dim myStack As Stack = New Stack()
SyncLock (Stack.Synchronized(myStack))
    For Each item As Object In myStack
        ' additional code for processing.
    Next
End SyncLock

3. You are creating a class library that will be used by several applications. You need to create a custom exception that will be thrown if an application attempts to retrieve product information using an invalid product number.
You need to create the ProductNotFoundException class. From which class should you derive ProductNotFoundException?
A: ApplicationException
B: SystemException
C: Exception
D: ArgumentException

No comments:

Post a Comment