Microsoft 70-536 Exam Practice Questions: Technology Specialist

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Muskad202
Muskad202
Community Contributor
Quizzes Created: 2 | Total Attempts: 7,118
Questions: 39 | Attempts: 5,174

SettingsSettingsSettings
Microsoft 70-536 Exam Practice Questions: Technology Specialist - Quiz

These are practice questions for the Microsoft Technology Specialist (TS) 70-536 Exam 70-210 developed for students and learners. There is a list of 40 questions. You can try these as a timed practice exam. The pass percentage is set to 75% for this set of practice questions. So, let's try out the quiz. All the best!


Questions and Answers
  • 1. 

    You are developing a .NET assembly which will be used from both, .NET components and COM components. How would you notify the caller that incorrect arguments were passed to a method?

    • A.

      Exception e = new Exception('Invalid argument'); e.HResult = 0x80070057; throw e;

    • B.

      Return Marshal.GetExceptionForHR(0x8007005);

    • C.

      Throw new ArgumentException('Invalid Argument');

    • D.

      Marshal.ThrowExceptionForHR(0x80070057);

    Correct Answer
    C. Throw new ArgumentException('Invalid Argument');
    Explanation
    The ArgumentException is a built-in .NET class, and .NET will automatically assign the correct value for the HResult. You should set HResult only for custom exception classes you create. The HResult value will be passed as the error code to the COM caller.

    Rate this question:

  • 2. 

    You are developing a .NET assembly which will be used from both, .NET components and COM components. Which 3 utilities do you need to use to ensure that COM components can access your assembly as easy as possible?

    • A.

      Signtool

    • B.

      Gacutil

    • C.

      Sn

    • D.

      Tlbimp

    • E.

      Regasm

    Correct Answer(s)
    B. Gacutil
    C. Sn
    E. Regasm
    Explanation
    sn for signing your assembly with a key.
    gacutil for placing it in the global assembly cache.
    regasm for creating the required entries in the registry.

    Rate this question:

  • 3. 

    You have created a custom event log using EventLog.CreateEventSource('A1','A2'); How would you write entries to this log?

    • A.

      EventLog log = new EventLog(); log.Source = "A1"; log.Log = "A2"; log.WriteData("data");

    • B.

      EventLog log = new EventLog(); log.Source = "A2"; log.Log = "A1"; log.WriteEvent("data");

    • C.

      EventLog log = new EventLog(); log.Source = "A1"; log.Log = "A2"; log.WriteEntry("data");

    • D.

      EventLog log = new EventLog(); log.Source = "A2"; log.Log = "A1"; log.WriteError("data");

    Correct Answer
    C. EventLog log = new EventLog(); log.Source = "A1"; log.Log = "A2"; log.WriteEntry("data");
    Explanation
    The first argument to CreateEventSource is the source name, and the second is the log name.

    Rate this question:

  • 4. 

    When you attempt to run an assembly, you receive a security exception. You realize that the assembly does not have sufficient permissions required for running. Which tool can you use to modify the assembly's permissions?

    • A.

      Caspol

    • B.

      Permview

    • C.

      Sn

    • D.

      Gacutil

    Correct Answer
    A. Caspol
    Explanation
    The Code Access Security Policy tool (caspol) is the one you need to use

    Rate this question:

  • 5. 

    What could you use to serialize an object 'obj' and write it to a stream 'outstream' using binary serialization?

    • A.

      BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(obj, outstream);

    • B.

      BinaryFormatter formatter = new BinaryFormatter(obj); formatter.Serialize(outstream);

    • C.

      BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(outstream, obj);

    • D.

      BinaryFormatter formatter = new BinaryFormatter(outstream); formatter.Serialize(obj);

    Correct Answer
    C. BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(outstream, obj);
    Explanation
    The correct answer is "BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(outstream, obj);" because it uses the BinaryFormatter class to serialize the object 'obj' and write it to the stream 'outstream'. The Serialize method of the BinaryFormatter class takes two parameters, the stream to write to and the object to serialize.

    Rate this question:

  • 6. 

    Your application has a number of debug messages which you write using Debug.WriteLine(). How would you display all these messages on the command line?

    • A.

      Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));

    • B.

      Debug.Listeners.Add(new StreamWriter(Console.Out));

    • C.

      Debug.Listeners.Add(new ConsoleTraceListener(Console.Out));

    • D.

      Debug.Listeners.Add(new StreamWriterTraceListener(Console.Out));

    Correct Answer
    C. Debug.Listeners.Add(new ConsoleTraceListener(Console.Out));
    Explanation
    TextWriterTraceListener is less efficient than ConsoleTraceListener. You cannot add a stream object to the Listeners collection, hence you cannot use StreamWriter. There is no object named StreamWriterTraceListener.

    Rate this question:

  • 7. 

    You have a custom object 'MyCustomObject' which you store in a list. You now want to enable a user to sort this list (containing instances of 'MyCustomObject'). However, on reading the documentation, you determine that in order to support sorting in a list, your object needs to implement a particular interface. What interface do you need to implement?

    • A.

      IComparable

    • B.

      IComparer

    • C.

      IEquatable

    • D.

      IEqualityComparer

    Correct Answer
    A. IComparable
    Explanation
    The IComparable interface is the one. It has a method named CompareTo, which is used to compare the current object instance with the one passed in via a parameter.

    Rate this question:

  • 8. 

    You have a function which should only be used by users who are part of the 'FavouriteUsers' group. You want to implement role-based security within the application. Which code snippet should you use?

    • A.

      WindowsIdentity user = WindowsIdentity.GetCurrent(); if (user.IsInRole("FavouriteUsers")) { //execute code }

    • B.

      WindowsGroup group = WindowsPrincipal.GetGroup("FavouriteUsers"); WindowsIdentity user = WindowsIdentity.GetCurrent(); if (group.Contains(user)) { //execute code }

    • C.

      If (Thread.CurrentPrincipal.IsInRole("FavouriteUsers")) { //execute code }

    • D.

      If (Thread.CurrentUser.IsMemberOf("FavouriteUsers")) { //execute code }

    Correct Answer
    C. If (Thread.CurrentPrincipal.IsInRole("FavouriteUsers")) { //execute code }
    Explanation
    The correct answer is "if (Thread.CurrentPrincipal.IsInRole("FavouriteUsers")) { //execute code }". This code snippet checks if the current principal (user) is in the "FavouriteUsers" role before executing the code. It uses the IsInRole method of the CurrentPrincipal property to determine if the user is a member of the specified role.

    Rate this question:

  • 9. 

    You want to copy a file from one location to another. You create two FileInfo objects' 'src' and 'dst' for this purpose which represent the source location and the destination location. You want to copy all the permissions which the original file has to the destination file. You also want to ensure that the destination file does not inherit the permissions of the destination directory in which it is placed. What code would you use?

    • A.

      FileSecurity permission = src.GetAccessControl(); permission.SetAccessRuleProtection(true, false); dst.SetAccessControl(permission);

    • B.

      FileSecurity permission = src.GetAccessControl(); permission.SetAccessRuleProtection(true, true); dst.SetAccessControl(permission);

    • C.

      FileSecurity permission = src.GetAccessControl(); permission.SetAccessRuleProtection(false, false); dst.SetAccessControl(permission);

    • D.

      FileSecurity permission = src.GetAccessControl(); permission.SetAccessRuleProtection(false, true); dst.SetAccessControl(permission);

    Correct Answer
    B. FileSecurity permission = src.GetAccessControl(); permission.SetAccessRuleProtection(true, true); dst.SetAccessControl(permission);
    Explanation
    The first parameter in SetAccessRuleProtection determines whether permissions can be modified/inherited from the destination directory. The second parameter determines whether the current permissions that are being inherited from the current source folder should be copied or not. We require that both these parameters are set to true.

    Rate this question:

  • 10. 

    You develop a library and want to ensure that the functions in the library cannot be either directly or indirectly invoked by applications that are not running on the local intranet. What attribute would you add to each method?

    • A.

      [UrlIdentityPermission(SecurityAction.RequestRefuse, Url="http://myintranet")]

    • B.

      [UrlIdentityPermission(SecurityAction.LinkDemand, Url="http://myintranet")]

    • C.

      [UrlIdentityPermission(SecurityAction.Demand, Url="http://myintranet")]

    • D.

      [UrlIdentityPermission(SecurityAction.Assert, Url="http://myintranet")]

    Correct Answer
    B. [UrlIdentityPermission(SecurityAction.LinkDemand, Url="http://myintranet")]
    Explanation
    LinkDemand should be used. it ensures that all callers in the call stack have the necessary permission .in this case it ensures that all callers in the call stack are on the local intranet.

    Rate this question:

  • 11. 

    How can you retrieve a reference to the current application domain?

    • A.

      AppDomain ad = AppDomain.Current;

    • B.

      AppDomain ad = Thread.GetDomain();

    • C.

      AppDomain ad = Thread.CurrentThread.CurrentDomain;

    • D.

      AppDomain ad = AppDomain.GetCurrentDomain();

    Correct Answer
    B. AppDomain ad = Thread.GetDomain();
    Explanation
    The correct answer is "AppDomain ad = Thread.GetDomain();". This line of code retrieves a reference to the current application domain by using the GetDomain() method of the Thread class. The GetDomain() method returns the AppDomain object that represents the application domain in which the current thread is executing.

    Rate this question:

  • 12. 

    You want to obtain a hash value for some data stored in a byte array, in order to detect if there is the corruption of the data. You use a HashAlgorithm object. Which code would you use to generate the hash?

    • A.

      Hash.Compute(byteArray);

    • B.

      Hash.ComputeHash(byteArray);

    • C.

      Hash = new HashAlgorithm(byteArray); hash.Compute();

    • D.

      Hash = new HashAlgorithm(byteArray); hash.ComputeHash();

    Correct Answer
    B. Hash.ComputeHash(byteArray);
    Explanation
    The correct code to generate the hash for the given scenario is "hash.ComputeHash(byteArray)". This code will use the HashAlgorithm object to compute the hash value for the data stored in the byte array. The ComputeHash method is specifically designed for this purpose and will generate the hash value that can be used to detect any corruption in the data.

    Rate this question:

  • 13. 

    You work in a company and need to send an email to a user, and a copy of that email to your manager. Which code should you use?

    Correct Answer
    B. MailMessage msg = new MailMessage("[email protected]", "[email protected]"); msg.CC.Add(new MailAddress("[email protected]")); msg.Subject = "..."; msg.Body = "..."; SmtpClient client = new SmtpClient(); client.Send(msg);
    Explanation
    You cannot assign strings to the To, From and CC fields since these are collections of MailAddress objects. The answer shows the proper syntax.

    Rate this question:

  • 14. 

    For the employees in a company, you need to store their salaries. Given an employee name, you want to find the salary as efficiently as possible. Currently, there are only 4 employees in the company, but you expect that number to go up to 100 by the year-end. Which object should you use?

    • A.

      StringCollection

    • B.

      HybridDictionary

    • C.

      HashTable

    • D.

      ArrayList

    Correct Answer
    B. HybridDictionary
    Explanation
    You should use the HybridDictionary since this class is efficient when the number of entries is small as well as large. The HashTable is not efficient when the number of entries is small. The StringCollection and ArrayList are not efficient for performing fast lookups � when the number of entries is small the performance hit may go unnoticed, but when the number of entries is large, they are much less efficient compared to HashTable and HybridDictionary.

    Rate this question:

  • 15. 

    You create an Employee object as such: [Serializable] public class Employee { public string Name; private long Salary; } When the employee object is serialized, you do not want the Salary field to be persisted. What is the easiest way to do this?

    • A.

      Add the NonSerialized attribute to the Salary field.

    • B.

      Have the Employee class implement ISerializable, and in the GetObjectData method, don't persist the Salary field.

    • C.

      Do nothing. since Salary is a private field.

    • D.

      Have the Employee class implement IFormatter for customizing the serialization process.

    Correct Answer
    A. Add the NonSerialized attribute to the Salary field.
    Explanation
    The easiest way to prevent the Salary field from being persisted when serializing the Employee object is to add the NonSerialized attribute to the Salary field. This attribute tells the serializer to ignore the field during the serialization process.

    Rate this question:

  • 16. 

    You write a function that calculates the square root of numbers. The number passed in as a parameter must be greater than or equal to 0. If the number is less than 0, then in your debug build, you want to display a message box to the user. What code would do this in the best possible way?

    • A.

      If (parameter < 0) MessageBox.Show("parameter cannot be less than 0");

    • B.

      #if DEBUG if (parameter < 0) MessageBox.Show("parameter cannot be less than 0"); #endif

    • C.

      Debug.Assert(parameter >= 0, "parameter cannot be less than 0");

    • D.

      If (parameter < 0) Debug.Assert("parameter cannot be less than 0");

    Correct Answer
    C. Debug.Assert(parameter >= 0, "parameter cannot be less than 0");
    Explanation
    The correct answer is Debug.Assert(parameter >= 0, "parameter cannot be less than 0"). This code uses the Debug.Assert method, which is specifically designed for debugging purposes. It checks if the parameter is less than 0 and if it is, it will display an assertion message with the specified error message. This helps in identifying and fixing issues during the debugging process.

    Rate this question:

  • 17. 

    Which methods of the FileStream class affect the Position property?

    • A.

      Read

    • B.

      Write

    • C.

      Seek

    • D.

      Lock

    • E.

      Unlock

    Correct Answer(s)
    A. Read
    B. Write
    C. Seek
    Explanation
    The methods of the FileStream class that affect the Position property are Read, Write, and Seek. The Read method reads a sequence of bytes from the current position in the file, advancing the Position property. The Write method writes a sequence of bytes to the current position in the file, also advancing the Position property. The Seek method sets the position within the file based on the specified offset, affecting the Position property accordingly. The Lock and Unlock methods are not related to the Position property and do not affect it.

    Rate this question:

  • 18. 

    You want to add a key-value pair to a HashTable 'table'. However, you need to make sure that the key doesn't already exist in the HashTable. What code could you use?

    • A.

      Try { table.Add(key, value); } catch (Exception e) { //key already exists }

    • B.

      If (table.Contains(key)) //key exists

    • C.

      If (table.ContainsKey(key)) //key exists

    • D.

      If (!table.TryAdd(key, value)) //key exists

    Correct Answer(s)
    B. If (table.Contains(key)) //key exists
    C. If (table.ContainsKey(key)) //key exists
    Explanation
    The correct answer is "if (table.Contains(key)) //key exists" and "if (table.ContainsKey(key)) //key exists" because both methods check if the key already exists in the HashTable. If the key exists, it means that the key-value pair cannot be added because it would result in a duplicate key.

    Rate this question:

  • 19. 

    What are the restrictions imposed on the signature of a method that is called when a serialization event occurs?

    • A.

      Must not have any parameters (void)

    • B.

      Must not return anything (void)

    • C.

      Must take a StreamingContext parameter

    • D.

      Must return a StreamingContext object

    Correct Answer(s)
    B. Must not return anything (void)
    C. Must take a StreamingContext parameter
    Explanation
    When a serialization event occurs, the method that is called must not return anything (void) because the serialization process does not expect any return value from the method. Additionally, the method must take a StreamingContext parameter because the StreamingContext object provides information about the source or destination of the serialized data.

    Rate this question:

  • 20. 

    You need to compress a Stream 'source file' and store the compressed bytes in another Stream 'destFile'. You also want to enable Cyclic Redundancy Checks in the compressed stream. What code would you use?

    • A.

      Void Compress(Stream sourceFile, Stream destFile) { GZipStream compStream = new GZipStream(destFile, CompressionMode.Compress); int theByte = sourceFile.ReadByte(); while (theByte != -1) { compStream.WriteByte((byte)theByte); theByte = sourceFile.ReadByte(); } compStream.Flush(); }

    • B.

      Void Compress(Stream sourceFile, Stream destFile) { GZipStream compStream = new GZipStream(sourceFile, CompressionMode.Compress); int theByte = compStream.ReadByte(); while (theByte != -1) { destFile.WriteByte((byte)theByte); theByte = compStream.ReadByte(); } destFile.Flush(); }

    • C.

      Void Compress(Stream sourceFile, Stream destFile) { DeflateStream compStream = new DeflateStream(destFile, CompressionMode.Compress); int theByte = sourceFile.ReadByte(); while (theByte != -1) { compStream.WriteByte((byte)theByte); theByte = sourceFile.ReadByte(); } compStream.Flush(); }

    • D.

      Void Compress(Stream sourceFile, Stream destFile) { DeflateStream compStream = new DeflateStream(sourceFile, CompressionMode.Compress); int theByte = compStream.ReadByte(); while (theByte != -1) { destFile.WriteByte((byte)theByte); theByte = compStream.ReadByte(); } destFile.Flush(); }

    Correct Answer
    A. Void Compress(Stream sourceFile, Stream destFile) { GZipStream compStream = new GZipStream(destFile, CompressionMode.Compress); int theByte = sourceFile.ReadByte(); while (theByte != -1) { compStream.WriteByte((byte)theByte); theByte = sourceFile.ReadByte(); } compStream.Flush(); }
    Explanation
    During both compression and decompression, the DeflateStream or GZipStream objects must wrap the stream that holds/will hold the compressed bytes.
    When using DeflateStream, no CRC checks are performed.

    Rate this question:

  • 21. 

    How would you send an HTML email message using MailMessage and SmtpClient?

    • A.

      MailMessage.IsSubjectHtml = true;

    • B.

      Set HTML content in the MailMessage.Subject field.

    • C.

      MailMessage.IsBodyHtml = true;

    • D.

      Set HTML content in the MailMessage.Body field.

    Correct Answer(s)
    C. MailMessage.IsBodyHtml = true;
    D. Set HTML content in the MailMessage.Body field.
    Explanation
    To send an HTML email message using MailMessage and SmtpClient, you need to set the property MailMessage.IsBodyHtml to true. This indicates that the content of the email body is in HTML format. Then, you can set the HTML content in the MailMessage.Body field, which will be sent as the body of the email.

    Rate this question:

  • 22. 

    You want to encrypt the network communication while sending an email to an smtp server. Which code should you use?

    • A.

      SmtpClient.EnableEncryption = true;

    • B.

      SmtpClient.UseEncryption = true;

    • C.

      =SmtpClient.EnableSsl = true;

    • D.

      SmtpClient.UseSsl = true;

    Correct Answer
    C. =SmtpClient.EnableSsl = true;
    Explanation
    The correct answer is "=SmtpClient.EnableSsl = true;". This is because the "EnableSsl" property is used to enable SSL encryption for the network communication with the SMTP server. SSL (Secure Sockets Layer) is a cryptographic protocol that provides secure communication over a network. By setting "EnableSsl" to true, the email communication will be encrypted, ensuring that the data sent between the client and the server is protected from unauthorized access.

    Rate this question:

  • 23. 

    If a class implements ISerializable, it needs to provide a constructor that takes two parameters. What are the types of those parameters?

    • A.

      BinaryFormatter

    • B.

      StreamingContext

    • C.

      ObjectManager

    • D.

      SerializationInfo

    Correct Answer(s)
    B. StreamingContext
    D. SerializationInfo
    Explanation
    If a class implements ISerializable, it needs to provide a constructor that takes two parameters. The first parameter is of type StreamingContext, which provides contextual information about the source or destination of the serialized data. The second parameter is of type SerializationInfo, which holds the serialized object data. These parameters are necessary for the class to properly deserialize and reconstruct the object from the serialized data.

    Rate this question:

  • 24. 

    Which code should you use to create a class that represents a Windows Service?

    • A.

      Class MyService : System.ServiceProcess.WindowsService { //implementation }

    • B.

      Class MyService : System.ServiceProcess.ServiceHost { //implementation }

    • C.

      Class MyService : System.ServiceProcess.ServiceBase { //implementation }

    • D.

      Class MyService : System.ServiceProcess.Service { //implementation }

    Correct Answer
    C. Class MyService : System.ServiceProcess.ServiceBase { //implementation }
    Explanation
    The correct answer is "class MyService : System.ServiceProcess.ServiceBase { //implementation }". This is because the ServiceBase class is the base class for creating a Windows Service in C#. It provides the necessary methods and properties to control the service's lifecycle, such as OnStart, OnStop, and OnPause. The other options (WindowsService, ServiceHost, and Service) are not valid base classes for creating a Windows Service.

    Rate this question:

  • 25. 

    You have a number of statements in your code that write lines to a Trace file. You use code as such: BooleanSwitch myTrace = new BooleanSwitch("MyTrace", "Used For Tracing"); Trace.WriteLineIf(myTrace.Enabled, "Test Trace Statement"); You want to toggle tracing on and off without having to recompile your application. What should you do?

    • A.

      Pass the command like argumeny "MyTrace:enabled" to your application.

    • B.

      Define a BooleanSwitch named "MyTrace" in the application configuration file, and set its value to "1".

    • C.

      Add a registry key named "MyTrace" in the appropriate location, and set its value to "1".

    • D.

      Prompt the user for the value of "MyTrace".

    Correct Answer
    B. Define a BooleanSwitch named "MyTrace" in the application configuration file, and set its value to "1".
    Explanation
    You should add the following to your app.config file:

    Rate this question:

  • 26. 

    You want to implement role-based security in your application. The group and user data and account information are stored in a database. You want your application to restrict/allow access to code based on the user's group membership. You want to write your application with the least amount of effort. What should you do?

    • A.

      Create custom classes that inherit from GenericIdentity and GenericPrincipal

    • B.

      Create objects of type GenericIdentity and GenericPrincipal

    • C.

      Create objects of type WindowsIdentity and WindowsPrincipal

    • D.

      Create custom classes that implement IIdentity and IPrincipal

    • E.

      Create custom classes that implement IWindowsIdentity and IWindowsPrincipal

    Correct Answer
    B. Create objects of type GenericIdentity and GenericPrincipal
    Explanation
    You could Create custom classes that implement Identity and IPrincipal, but this would be more effort as compared to creating objects of type Generic Identity and Generic Principle.

    Rate this question:

  • 27. 

    Within your application, you need to monitor and control a service installed on the local machine. Which class do you need to use?

    • A.

      ServiceController

    • B.

      ServiceHost

    • C.

      ServiceManager

    • D.

      ServiceMonitor

    • E.

      ServiceBase

    Correct Answer
    A. ServiceController
    Explanation
    You can use code like:
    ServiceController controller = new ServiceController('ServiceName');
    controller.Start();
    MessageBox.Show(controller.Status.ToString());

    Rate this question:

  • 28. 

    You want to display the names of all currently running processes. What could can you use?

    • A.

      Foreach (Process p in Process.GetRunningProcesses()) MessageBox.Show(p.ProcessName);

    • B.

      Foreach (Process p in Process.GetCurrentProcesses()) MessageBox.Show(p.ProcessName);

    • C.

      Foreach (Process p in Process.GetProcesses()) MessageBox.Show(p.ProcessName);

    • D.

      Foreach (Process p in Process.GetUserProcesses()) MessageBox.Show(p.ProcessName);

    Correct Answer
    C. Foreach (Process p in Process.GetProcesses()) MessageBox.Show(p.ProcessName);
    Explanation
    The correct answer is "foreach (Process p in Process.GetProcesses()) MessageBox.Show(p.ProcessName);". This code uses the GetProcesses() method from the Process class to retrieve all currently running processes. It then uses a foreach loop to iterate through each process and display its name using the MessageBox.Show() method.

    Rate this question:

  • 29. 

    You've created a function named 'MyFunction' which you want to be called every 10 minutes. You decide to use the Timer class. You write another function called 'StartTimer' which you will use to start the Timer. Also, when 'StartTimer' is called, you want 'MyFunction' to be called the moment the timer is started. What code would you use?

    • A.

      Void StartTimer() { Timer myTimer = new Timer(new TimerCallback(MyFunction), null, 600000, 0); }

    • B.

      Void StartTimer() { Timer myTimer = new Timer(new TimerCallback(MyFunction), null, 0, 600000); }

    • C.

      Void StartTimer() { Timer myTimer = new Timer(new TimerCallback(MyFunction), null, 600000, 600000); }

    • D.

      Void StartTimer() { Timer myTimer = new Timer(new TimerCallback(MyFunction), null, 1, 600000); }

    Correct Answer
    B. Void StartTimer() { Timer myTimer = new Timer(new TimerCallback(MyFunction), null, 0, 600000); }
    Explanation
    The second argument specifies the parameter which will be passed to 'MyFunction'. The 3rd parameter specifies the delay (in milliseconds) before calling 'MyFunction' the first time. The 4th parameter specifies the interval (in milliseconds) between successive calls to 'MyFunction'.

    Rate this question:

  • 30. 

    You want to use IsolatedStorage to store user settings for your application. What could you use?

    • A.

      IsolatedStorageFile userStore = IsolatedStorageFile.GetUserStoreForAssembly(); IsolatedStorageFileStream stream = new IsolatedStorageFileStream("filename", FileMode.Create, userStore); StreamWriter sw = new StreamWriter(stream); sw.WriteLine("user settings"); sw.Close();

    • B.

      IsolatedStorageFile userStore = IsolatedStorageFile.GetMachineStoreForAssembly(); IsolatedStorageFileStream stream = new IsolatedStorageFileStream("filename", FileMode.Create, userStore); StreamWriter sw = new StreamWriter(stream); sw.WriteLine("user settings"); sw.Close();

    • C.

      IsolatedStorageFile userStore = IsolatedStorageFile.GetUserStoreForAssembly(); IsolatedStorageFileStream stream = new IsolatedStorageFileStream("filename", FileMode.Create, userStore); IsolatedStorageFileStreamWriter sw = new IsolatedStorageFileStreamWriter(stream); sw.WriteLine("user settings"); sw.Close();

    • D.

      IsolatedStorageFile userStore = IsolatedStorageFile.GetMachineStoreForAssembly(); IsolatedStorageFileStream stream = new IsolatedStorageFileStream("filename", FileMode.Create, userStore); IsolatedStorageFileStreamWriter sw = new IsolatedStorageFileStreamWriter(stream); sw.WriteLine("user settings"); sw.Close();

    Correct Answer
    A. IsolatedStorageFile userStore = IsolatedStorageFile.GetUserStoreForAssembly(); IsolatedStorageFileStream stream = new IsolatedStorageFileStream("filename", FileMode.Create, userStore); StreamWriter sw = new StreamWriter(stream); sw.WriteLine("user settings"); sw.Close();
    Explanation
    You should not use GetMachineStoreForAssembly because then the file will be shared among all the users of the application. Also, you should use StreamWriter for accessing the files.

    Rate this question:

  • 31. 

    You want to use the Rijndael encryption method for encrypting an input file and storing the encrypted data in an output file. What code would you use?

    • A.

      String inFileName = "input file path"; string outFileName = "encrypted file path"; FileStream inFile = new FileStream(inFileName, FileMode.Open, FileAccess.Read); FileStream outFile = new FileStream(outFileName, FileMode.OpenOrCreate, FileAccess.Write); SymmetricAlgorithm myAlg = new RijndaelManaged(); myAlg.GenerateKey(); byte[] fileData = new byte[inFile.Length]; inFile.Read(fileData, 0, (int)inFile.Length); ICryptoTransform encryptor = myAlg.CreateEncryptor(); CryptoStream encryptStream = new CryptoStream(outFile, encryptor, CryptoStreamMode.Write); encryptStream.Write(fileData, 0, fileData.Length); encryptStream.Close(); inFile.Close(); outFile.Close();

    • B.

      String inFileName = "input file path"; string outFileName = "encrypted file path"; FileStream inFile = new FileStream(inFileName, FileMode.Open, FileAccess.Read); FileStream outFile = new FileStream(outFileName, FileMode.OpenOrCreate, FileAccess.Write); SymmetricAlgorithm myAlg = new RijndaelManaged(); myAlg.GenerateKey(); byte[] fileData = new byte[inFile.Length]; ICryptoTransform encryptor = myAlg.CreateEncryptor(); CryptoStream encryptStream = new CryptoStream(inFile, encryptor, CryptoStreamMode.Read); encryptStream.Read(fileData, 0, inFile.Length); outFile.Write(fileData, 0, (int)fileData.Length); encryptStream.Close(); inFile.Close(); outFile.Close();

    • C.

      String inFileName = "input file path"; string outFileName = "encrypted file path"; FileStream inFile = new FileStream(inFileName, FileMode.Open, FileAccess.Read); FileStream outFile = new FileStream(outFileName, FileMode.OpenOrCreate, FileAccess.Write); SymmetricAlgorithm myAlg = new RijndaelManaged(); myAlg.GenerateKey(); byte[] fileData = new byte[inFile.Length]; inFile.Read(fileData, 0, (int)inFile.Length); ICryptoTransform encryptor = myAlg.CreateEncryptor(); CryptoStream encryptStream = new CryptoStream(outFile, encryptor, CryptoStreamMode.Read); encryptStream.Write(fileData, 0, fileData.Length); encryptStream.Close(); inFile.Close(); outFile.Close();

    • D.

      String inFileName = "input file path"; string outFileName = "encrypted file path"; FileStream inFile = new FileStream(inFileName, FileMode.Open, FileAccess.Read); FileStream outFile = new FileStream(outFileName, FileMode.OpenOrCreate, FileAccess.Write); SymmetricAlgorithm myAlg = new RijndaelManaged(); myAlg.GenerateKey(); byte[] fileData = new byte[inFile.Length]; ICryptoTransform encryptor = myAlg.CreateEncryptor(); CryptoStream encryptStream = new CryptoStream(inFile, encryptor, CryptoStreamMode.Write); encryptStream.Read(fileData, 0, inFile.Length); outFile.Write(fileData, 0, (int)fileData.Length); encryptStream.Close(); inFile.Close(); outFile.Close();

    Correct Answer
    A. String inFileName = "input file path"; string outFileName = "encrypted file path"; FileStream inFile = new FileStream(inFileName, FileMode.Open, FileAccess.Read); FileStream outFile = new FileStream(outFileName, FileMode.OpenOrCreate, FileAccess.Write); SymmetricAlgorithm myAlg = new RijndaelManaged(); myAlg.GenerateKey(); byte[] fileData = new byte[inFile.Length]; inFile.Read(fileData, 0, (int)inFile.Length); ICryptoTransform encryptor = myAlg.CreateEncryptor(); CryptoStream encryptStream = new CryptoStream(outFile, encryptor, CryptoStreamMode.Write); encryptStream.Write(fileData, 0, fileData.Length); encryptStream.Close(); inFile.Close(); outFile.Close();
    Explanation
    The CryptoStream object should wrap the stream that holds / will hold the encrypted data. Also, the CryptoStreamMode parameter should reflect the operation that will be carried out on the encrypted stream. Therefore, for encryption, since you will be writing to the encrypted stream, this parameter should be CryptoStreamMode.Write

    Rate this question:

  • 32. 

    You want to use the RSA algorithm to encrypt a string 'messageString' and obtain the encrypted bytes. What code would you use?

    • A.

      RSACryptoServiceProvider myRsa = new RSACryptoServiceProvider(); byte[] messageBytes = Encoding.Unicode.GetBytes(messageString); myRsa.Encrypt(messageBytes); byte[] encryptedBytes = new byte[messageBytes.Length]; myRsa.GetEncryptedBytes(encryptedBytes);

    • B.

      RSACryptoServiceProvider myRsa = new RSACryptoServiceProvider(); byte[] messageBytes = Encoding.Unicode.GetBytes(messageString); byte[] encryptedMessage = myRsa.Encrypt(messageBytes, false);

    • C.

      RSACryptoServiceProvider myRsa = new RSACryptoServiceProvider(); byte[] messageBytes = Encoding.Unicode.GetBytes(messageString); myRsa.Read(messageBytes); byte[] encryptedBytes = new byte[messageBytes.Length]; myRsa.Write(encryptedBytes);

    • D.

      RSACryptoServiceProvider myRsa = new RSACryptoServiceProvider(); byte[] encryptedMessage = myRsa.Encrypt(messageString, false);

    Correct Answer
    B. RSACryptoServiceProvider myRsa = new RSACryptoServiceProvider(); byte[] messageBytes = Encoding.Unicode.GetBytes(messageString); byte[] encryptedMessage = myRsa.Encrypt(messageBytes, false);
    Explanation
    The correct answer is RSACryptoServiceProvider myRsa = new RSACryptoServiceProvider(); byte[] messageBytes = Encoding.Unicode.GetBytes(messageString); byte[] encryptedMessage = myRsa.Encrypt(messageBytes, false). This code correctly initializes an instance of the RSACryptoServiceProvider class, converts the message string to bytes using the Unicode encoding, and then encrypts the message bytes using the RSA algorithm with the specified padding mode (in this case, false indicates no padding). The encrypted message is stored in the encryptedMessage byte array.

    Rate this question:

  • 33. 

    What code would you use (using Management Objects) to retrieve a list of logical drives on a machine?

    • A.

      ConnectionOptions DemoOptions = new ConnectionOptions(); DemoOptions.Username = "username"; DemoOptions.Password = "password"; ManagementScope DemoScope = new ManagementScope("machinename", DemoOptions); ObjectQuery DemoQuery = new ObjectQuery("SELECT Size, Name FROM Win32_LogicalDisk where DriveType=3"); ManagementObjectSearcher DemoSearcher = new ManagementObjectSearcher(DemoScope, DemoQuery); ManagementObjectCollection AllObjects = DemoSearcher.Get(); foreach (ManagementObject DemoObject in AllObjects) { Console.WriteLine("Resource Name: " + DemoObject["Name"].ToString()); Console.WriteLine("Resource Size: " + DemoObject["Size"].ToString()); }

    • B.

      ConnectionOptions DemoOptions = new ConnectionOptions(); DemoOptions.Username = "username"; DemoOptions.Password = "password"; ManagementScope DemoScope = new ManagementScope("machinename", DemoOptions); ObjectQuery DemoQuery = new ObjectQuery("SELECT Size, Name FROM Win32_LogicalDisk where DriveType=3"); ManagementObjectSearcher DemoSearcher = new ManagementObjectSearcher(DemoScope, DemoQuery); ManagementObjectCollection AllObjects = DemoSearcher.Get(); foreach (ManagementObject DemoObject in AllObjects) { Console.WriteLine("Resource Name: " + DemoObject.Name); Console.WriteLine("Resource Size: " + DemoObject.Size); }

    • C.

      ConnectionOptions DemoOptions = new ConnectionOptions(); DemoOptions.Username = "username"; DemoOptions.Password = "password"; ManagementScope DemoScope = new ManagementScope("machinename", DemoOptions); ManagementObjectQuery DemoQuery = new ManagementObjectQuery("SELECT Size, Name FROM Win32_LogicalDisk where DriveType=3"); ManagementObjectSearcher DemoSearcher = new ManagementObjectSearcher(DemoScope, DemoQuery); ManagementObjectCollection AllObjects = DemoSearcher.Get(); foreach (ManagementObject DemoObject in AllObjects) { Console.WriteLine("Resource Name: " + DemoObject.Name); Console.WriteLine("Resource Size: " + DemoObject.Size); }

    • D.

      ConnectionOptions DemoOptions = new ConnectionOptions(); DemoOptions.Username = "username"; DemoOptions.Password = "password"; ManagementScope DemoScope = new ManagementScope("machinename", DemoOptions); ManagementObjectQuery DemoQuery = new ManagementObjectQuery("SELECT Size, Name FROM Win32_LogicalDisk where DriveType=3"); ManagementObjectSearcher DemoSearcher = new ManagementObjectSearcher(DemoScope, DemoQuery); ManagementObjectCollection AllObjects = DemoSearcher.Get(); foreach (ManagementObject DemoObject in AllObjects) { Console.WriteLine("Resource Name: " + DemoObject["Name"].ToString()); Console.WriteLine("Resource Size: " + DemoObject["Size"].ToString()); }

    Correct Answer
    A. ConnectionOptions DemoOptions = new ConnectionOptions(); DemoOptions.Username = "username"; DemoOptions.Password = "password"; ManagementScope DemoScope = new ManagementScope("machinename", DemoOptions); ObjectQuery DemoQuery = new ObjectQuery("SELECT Size, Name FROM Win32_LogicalDisk where DriveType=3"); ManagementObjectSearcher DemoSearcher = new ManagementObjectSearcher(DemoScope, DemoQuery); ManagementObjectCollection AllObjects = DemoSearcher.Get(); foreach (ManagementObject DemoObject in AllObjects) { Console.WriteLine("Resource Name: " + DemoObject["Name"].ToString()); Console.WriteLine("Resource Size: " + DemoObject["Size"].ToString()); }
    Explanation
    The given code snippet uses Management Objects to retrieve a list of logical drives on a machine. It first creates a ConnectionOptions object and sets the username and password for authentication. Then, it creates a ManagementScope object with the machine name and the ConnectionOptions. Next, it creates an ObjectQuery object with the query to select the logical drives with DriveType=3 (which represents local disk drives). After that, it creates a ManagementObjectSearcher object with the ManagementScope and ObjectQuery. It then calls the Get() method on the ManagementObjectSearcher to retrieve all the matching objects. Finally, it iterates over the ManagementObjectCollection and prints the name and size of each logical drive.

    Rate this question:

  • 34. 

    What method would you call on an object of type DirectoryInfo to retrieve a list of all subdirectories under that directory?

    • A.

      GetSubDirectories

    • B.

      GetDirectories

    • C.

      GetFileSystemInfos

    • D.

      GetFiles

    Correct Answer
    B. GetDirectories
    Explanation
    GetFileSystemInfos retrieves a list of both files and subdirectories. There is no method called GetSubDirectories.

    Rate this question:

  • 35. 

    While writing a file using StreamWriter, how would you specify the encoding to use?

    • A.

      Specify the encoding in the StreamWriter constructor

    • B.

      Set the encoding using the StreamWriter.Encoding property.

    • C.

      Set the encoding using the StreamWriter.SetEncoding method

    • D.

      Set the encoding using the StreamWriter.CodePage property

    Correct Answer
    A. Specify the encoding in the StreamWriter constructor
    Explanation
    There is no method called SetEncoding(). The Encoding property is readonly. There is no property called CodePage.

    Rate this question:

  • 36. 

    You are implementing a data structure, where in you want to store keys which are strings, and you want to store values associated with the keys, which are also strings. There can be multiple values associated with a key. What class would you use to minimize the development effort, while at the same time maximizing efficiency?

    • A.

      Dictionary>;

    • B.

      List;

    • C.

      StringDictionary;

    • D.

      NameValueCollection

    Correct Answer
    D. NameValueCollection
    Explanation
    You could also use Dictionary, but this would require additional code when storing and retrieving data in it.

    Rate this question:

  • 37. 

    In order to use the for each statement, what interface needs to be implemented by the target class?

    • A.

      IEnumerable

    • B.

      IEnumerator

    • C.

      ICollection

    • D.

      IList

    Correct Answer
    B. IEnumerator
    Explanation
    The correct answer is IEnumerator. The for each statement is used to iterate over a collection of items. In order to use this statement, the target class needs to implement the IEnumerator interface. This interface provides the necessary methods for iterating over the collection, such as MoveNext() to move to the next item and Current to get the current item. By implementing this interface, the target class can be used in a for each loop to iterate over its items.

    Rate this question:

  • 38. 

    Which interface should you implement in order to allow instances of your class to be converted to an instance of another type?

    • A.

      ITypeConverter

    • B.

      ITypeConvertible

    • C.

      IConvertible

    • D.

      IConverter

    Correct Answer
    C. IConvertible
    Explanation
    The IConvertible interface contains the signatures for about 17 functions, like ToInt32(), ToDateTime(), GetTypeCode(), ToType(), etc.

    Rate this question:

  • 39. 

    What class would you use in order to create a Font from a string that contains the font definition?

    • A.

      Font ' The Font class has a method that understands a string description of a font

    • B.

      FontConverter

    • C.

      FontConvertible

    • D.

      FontType

    Correct Answer
    B. FontConverter
    Explanation
    The correct answer is FontConverter. The FontConverter class is used to create a Font object from a string that contains the font definition. This class has a method that understands the string description of a font and converts it into a Font object.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Sep 18, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Nov 19, 2006
    Quiz Created by
    Muskad202

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.