Search this blog

You can search for all the topics in our blog using our google custom search now.

Search the blog

Loading

Saturday, December 25, 2010

Technology Focus Questions 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: StringCollectionmyStrCol = new StringCollection();
02: myStrCol.AddRange(GetStrings());
03: StringEnumeratormyEnumerator = 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()
SyncLockmyStack.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


QUESTIONS Technology Focus: Implementing service processes, threading, and applications domains in a .NET Framework application
1. You create a Windows service application that consists of two services. One service monitors a directory for new orders and the other service replicates a database table with the most up-to-date inventory information.You need to develop a project installer class to install these services.What should you do? (Each correct answer presents part of the solution. Choose two.).

A. Instantiate one ServiceProcessInstaller instance and add it to the project installer class.
B. Instantiate two ServiceInstaller instances and add them to the project installer class.
C. Instantiate two ServiceProcessInstaller instances and add them to the project installer class.
D. Instantiate one ServiceInstaller instance and add it to the project installer class.
E. Instantiate one ComponentInstaller instance and add it to the project installer class.
F. Instantiate two ComponentInstaller instances and add them to the project installer class.

2. You are developing a Windows service application by using the .NET Framework. You need the application to perform several short tasks that require background processing. You do not want to actively manage threads in your application. You must ensure that security checks are performed during the execution of a task. Which method should you use to start a task in your application?
A. ThreadPool.QueueUserWorkItem
B. ThreadPool.UnsafeQueueUserWorkItem
C. Thread.Start
D. Thread.Resume

3. You are developing a Windows service application by using the .NET Framework. You need to synchronize execution of some resources across multiple processes. Which class should you use to accomplish this in your application?
A. Mutex (THIS IS THE ANSWER)
B. Monitor
C. Interlocked
D. Mutex
QUESTIONS Technology Focus: Embedding configuration, diagnostic, management, and installation features into a .NET Framework application
1. You develop a Windows application by using the .NET Framework. The application makes use of an assembly named MyAssembly. The assembly file MyAssembly.d11 is deployed in a folder named bin20 under the application's root directory. The MyAssembly assembly is not strongly named.
You must configure the Windows application to specify the location of the MyAssembly assembly. Any settings that you change must not affect other applications installed on the system. What should you do?
A. Modify the application configuration file to add the following settings to the section:
B. Modify the application configuration file to add the following settings to the section: >
C. Modify the machine configuration file and add the following settings to the section for the MyAssembly assembly:
D. Modify the machine configuration file and add the following settings to the section for the MyAssembly assembly:

2. You have deployed an application that uses a dependent assembly named TaxCalc. It was written to work with version 1.1.3.6 of TaxCalc, but has been tested successfully through version 2.1.1.0. The user updates the TaxCalc assembly to version 2.1.1.2 and your application no longer runs.
Several other applications on the computer use TaxCalc. The other applications on the computer can run with the new version of TaxCalc.You need to ensure that your application works with a supported version of TaxCalc that is installed on the computer. Your solution should allow other applications to continue to use the latest version of TaxCalc.What should you do?
A. Add the following to the publisher configuration file for the TaxCalc assembly:
  


name="TaxCalc"
publicKeyToken="12345abcde12345bcdef12345abcde" />

/>
B. Add the following to the application configuration file:
publicKeyToken="12345abcde12345bcdef12345abcde" oldVersion="1.1.3.6-2.1.1.2"
newVersion="2.1.1.0" />
C. Add the following to the application configuration file:
publicKeyToken="12345abcde12345bcdef12345abcde" />
D. Add the following to the publisher configuration file:
publicKeyToken="12345abcde12345bcdef12345abcde" oldVersion="2.1.1.2"
newVersion="1.1.3.6-2.1.1.0" />

3. You are developing a .NET Framework application. When a user's attempt to log on to the application fails, you must write an entry to the Windows event log. When looking at the Windows event log viewer, the source of the events must be listed as MyApp.You need to create an event source that can be used to write entries to the event log. Which code segment should you use?
Option A
C#
EventLog.LogNameFromSourceName("MyApp", "Security");
Visual Basic
EventLog.LogNameFromSourceName("MyApp", "Security")


Option B
C#
if(!EventLog.SourceExists("MyApp"))
{
  EventLog.CreateEventSource("MyApp", "Application");
}
Visual Basic
If Not EventLog.SourceExists("MyApp") Then
    EventLog.CreateEventSource("MyApp", "Application")
End If


Option C
C#
if(!EventLog.SourceExists("MyApp"))
{
  EventLog.CreateEventSource("MyApp", "Security");
}
Visual Basic
If Not EventLog.SourceExists("MyApp") Then
    EventLog.CreateEventSource("MyApp", "Security")
End If


Option D
C#
EventLog.LogNameFromSourceName("MyApp", "Application");
Visual Basic
EventLog.LogNameFromSourceName("MyApp", "Application")

QUESTIONS Technology Focus:Implementing serialization and input/output functionality in a .NET Framework application
1. You are developing a logging module for a large application by using the .NET Framework.You need to append logging information to a file named application.log. This log file is opened when the application is started and is closed only when the application is closed. However, you append text several times to the file during a session.
You must minimize overhead to the logging process to ensure maximum performance.Which code segment should you use to create the log file?
Option A:
C#
StreamWritersw = File.CreateText(@"c:\application.log");
Visual Basic
Dim sw As StreamWriter = File.CreateText("c:\application.log")


Option B:
C#
FileInfo fi = new FileInfo(@"c:\application.log");
FileStreamfs = fi.Open(FileMode.Append);
Visual Basic
Dim fi As FileInfo = New FileInfo("c:\application.log")
Dim fs As FileStream = fi.Open(FileMode.Append)


Option C:
C#
FileInfo fi = new FileInfo(@"c:\application.log");
StreamWritersw = fi.AppendText();
Visual Basic
Dim fi As FileInfo = New FileInfo("c:\application.log")
Dim sw As StreamWriter = fi.AppendText()


Option D
C#
EventLog.LogNameFromSourceName("MyApp", "Application");
Visual Basic
EventLog.LogNameFromSourceName("MyApp", "Application")

2. You are developing a class library by using the .NET Framework. You create the following classes:
C#
public class Book
{
    public string Name;
}
public class Encyclopedia : Book
{
    public int Volume;
}
Visual Basic
Public Class Book
    Public Name As String
End Class
Public Class Encyclopedia
    Inherits Book
    Public Volume As Integer
End Class
You must be able to serialize the objects of the Encyclopedia class to a disk file. What should you do?
Option A:
C#
Add the [Serializable] attribute to the Book class only.
Visual Basic
Add the attribute to the Book class only.


Option B:
C#
Add the [Serializable] attribute to the Encyclopedia class only.
Visual Basic
Add the attribute to the Encyclopedia class only.


Option C:
C#
Add the [Serializable] attribute to the Book class.
Add the [Serializable] attribute to the Encyclopedia class.
Visual Basic
Add the attribute to the Book class.
Add the attribute to the Encyclopedia class.


Option D:
C#
Add the [Serializable] attribute to the Encyclopedia class.
Add the [NonSerialized] attribute to the Name field.
Visual Basic
Add the attribute to the Encyclopedia class.
Add the attribute to the Name field.

3. You are developing a Windows application by using the .NET Framework. The application uses a shared assembly for personalizing the user interface of the application.The same assembly is used by several other applications on the user's machine. Any changes in the user preferences in one application must be carried over to other applications.
You need to access the user's preferences for displaying the user interface.What should you do?
A: Use the IsolatedStorageFile.GetMachineStoreForAssembly method
B: Use the IsolatedStorageFile.GetMachineStoreForDomain method.
C. Use the IsolatedStorageFile.GetUserStoreForDomain method.
D: Use the IsolatedStorageFile.GetUserStoreForAssembly method.
QUESTIONS Technology Focus:Improving the security of .NET Framework applications by using the NET Framework security features
1. You use the .NET Framework to develop a client-server application. The server part of the application runs on a computer running Microsoft Windows Server 2003. All client computers run Microsoft Windows XP Professional. You need to write code that performs authentication and establishes a secure connection between the server and the client. You must make sure that the Kerberos protocol is used for authentication.
You must also make sure that data is encrypted before it is transmitted over the network and decrypted when it reaches the destination. Which code segment should you use?
Option A:
C#
public void NetMethod(NetworkCredential credentials, Stream innerStream)
{
    NegotiateStream ns = new NegotiateStream(innerStream);
    ns.AuthenticateAsServer(credentials, ProtectionLevel.EncryptAndSign,
        TokenImpersonationLevel.Impersonation);
    // Additional code
}
Visual Basic
Public Sub NetMethod( _
    ByVal credentials As NetworkCredential, _
    ByValinnerStream As Stream)
    Dim ns As NegotiateStream = New NegotiateStream(innerStream)
    ns.AuthenticateAsServer(credentials, ProtectionLevel.EncryptAndSign, _
    TokenImpersonationLevel.Impersonation)
    ' Additional code
End Sub


Option B:
C#
public void NetMethod(NetworkCredential credentials, Stream innerStream)
{
    NegotiateStream ns = new NegotiateStream(innerStream);
    ns.AuthenticateAsServer(credentials, ProtectionLevel.Sign,
        TokenImpersonationLevel.Impersonation);
    // Additional code
}
Visual Basic
Public Sub NetMethod( _
    ByVal credentials As NetworkCredential, _
    ByValinnerStream As Stream)
    Dim ns As NegotiateStream = New NegotiateStream(innerStream)
    ns.AuthenticateAsServer(credentials, ProtectionLevel.Sign, _
    TokenImpersonationLevel.Impersonation)
    ' Additional code
End Sub


Option C:
C#
public void NetMethod(X509Certificate serverCertificate, Stream innerStream)
{
    SslStreamss = new SslStream(innerStream);
    ss.AuthenticateAsServer(serverCertificate, true,
        SslProtocols.Tls, true);
    // Additional code
}
Visual Basic
Public Sub NetMethod( _
    ByValserverCertificate As X509Certificate, _
    ByValinnerStream As Stream)
    Dim ss As SslStream = New SslStream(innerStream)
    ss.AuthenticateAsServer(serverCertificate, True, _
        SslProtocols.Tls, True)
    ' Additional code
End Sub


Option D:
C#
public void NetMethod(X509Certificate serverCertificate, Stream innerStream)
{
    SslStreamss = new SslStream(innerStream);
    ss.AuthenticateAsServer(serverCertificate, true,
        SslProtocols.Ssl3, true);
    // Additional code
}
Visual Basic
Public Sub NetMethod( _
    ByValserverCertificate As X509Certificate, _
    ByValinnerStream As Stream)
    Dim ss As SslStream = New SslStream(innerStream)
    ss.AuthenticateAsServer(serverCertificate, True, _
        SslProtocols.ssl3, True)
    ' Additional code
End Sub


2. You develop a .NET Framework application. This application is deployed throughout the company on all workstations. All workstations are networked and are part of a Microsoft Windows domain.
Your application requires certain permissions in order to run. As a domain administrator, you configure the enterprise policy to grant the required permissions to the application. This application may be part of more than one code group.
You must make sure that your application receives sufficient permissions to run at all times. You must override any policy changes made by end users that lower the permissions required by your application to run.What should you do?
A: Apply the Exclusive attribute to the application's code group on the enterprise policy level.
B: Apply the LevelFinal attribute to the application's code group on the user policy level.
C: Apply the LevelFinal attribute to the application's code group on the enterprise policy level.
D: Apply the Exclusive attribute to the application's code group on the user policy level.

3. You develop a .NET Framework application. The assembly is added to these four code groups at the Enterprise level policy:
* All Code code group with a permission set of Everything
* Known Code code group with a permission set of Local Intranet
* Unknown Code code group with a permission set of Internet
* Restricted Code code group with a permission set of Nothing
The assembly is not a member of any other code groups.When the assembly is executed, what permissions does the Common Language Runtime (CLR) assign to the assembly?
A: Internet
B: Everything
C: Local Intranet
D: Nothing


2 comments:

  1. i need answer 3 question friend .. can u send me prasad.anumolu@gmail.com

    ReplyDelete