Mock Test 3

  1. In your application, you have implemented the LogException(string message) method to log exceptions. When an exception is thrown from your application, you want to log and rethrow the original exception. How do you achieve this?
    1. catch(Exception ex){LogException(ex.Message); throw;}

    2. catch(Exception ex){LogException(ex.Message); throw ex;}

    3. catch{LogException(ex.Message); throw new Exception();}

    4. catch{LogException(ex.Message); rethrow;}

  2. You have created an application where you have implemented custom exception types and have also implemented multiple log methods, as follows:
public class CustomException1 : System.Exception{}
public class CustomException2 : CustomException1 {}
public class CustomException3 : CustomException1{}

void Log(Exception ex){}
void Log(CustomException2 ex) {}
void Log(CustomException3 ex) {}

You have a method that can throw one of the preceding exceptions. You need to make sure that, when the exception is caught, a log exception message by the log method accepts the exception; when CustomException2 is caught, a log message by the log method accepts CustomException2; and the same for CustomException3. How do you want to achieve this?  Please specify the order of catch statements:

    1. catch(CustomException1 ex){...}
      catch(CustomExceotion2 ex){...}
      catch(CustomException3 ex){...}
    2. catch(Exception ex){...}
      catch(CustomExceotion2 ex){...}
      catch(CustomException3 ex){...}
    3. catch(Exception ex){...}
      catch(CustomExceotion1 ex){...}
    4. catch(CustomException3 ex){...}
      catch(CustomExceotion2 ex){...}
      catch(Exception ex){...}
  1. Your application is running multiple tasks using a task factory. However, a customer has requested you to run a specific task when its parent task throws an exception. How do you achieve this?
    1. task.when()
    2. task.whenany()
    3. task.continuewhenany()
    4. None of the above
  2. Your application is running multiple worker threads. How do you make sure that your application waits for all the threads to complete their execution?
    1. Thread.Sleep()
    2. Thread.WiatALL()
    3. Thread.Join()
    4. None of the above
  3. Secret key encryption is also known as asymmetric encryption.
    1. True
    2. False
  1. In public-key encryption, anyone with the public key can process the message.
    1. True
    2. False
  2. When using RSACryptoServiceProvider in your sample application, how would you get your public and private keys?
    1. RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
      string publicKey = rsa.ToXmlString(false);
      string pricateKey = rsa.ToXmlString(true);
    2. RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
      string publicKey = rsa.ToXmlString(true);
      string pricateKey = rsa.ToXmlString(false);
    3. RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
      string publicKey = rsa.ToXmlString(public);
      string pricateKey = rsa.ToXmlString(private);
    4. RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
      string publicKey = rsa.ToXmlString("public");
      string pricateKey = rsa.ToXmlString("private");
  3. What is the best way to authenticate a sender?
    1. Encrypt your message.
    2. Sign your message.
    3. Use digital signatures.
    4. All of the above.
  4. When you apply the hash algorithm on a string, what will the output be?
    1. The string gets encrypted.
    2. Each character gets hashed into a different binary string.
    3. The string gets hashed as a whole.
    4. None of the above.
  1. You are adding new features to an existing application for your customers. When you deploy them, you get an assembly manifest mismatch error. What is the best possible solution to resolve this issue?
    1. Update all major and minor assembly versions of the current and dependent assemblies, then rebuild and deploy.
    2. Check all assembly versions of the current and dependent assemblies and make sure the configurations or policies are updated to reflect the change in assembly versions, then rebuild and deploy.
    3. Update the machine.config file to ignore such errors.
    4. Update web.config and set the custom error mode to off.
  2. You create a release package and deploy your application into a production environment. When users start using the application, they receive an error. You are unable to reproduce it in any lower-level environments, so you decide to debug your application in the production environment. However, the application never stops at the breakpoint. Why is this?
    1. You don't have local admin permissions on the system.
    2. Visual Studio's debugging module is not loaded.
    3. The release version doesn't allow us to debug.
    4. All of the above.
  3. You create an application and you want to monitor it while it is executing. So, you decide to implement tracing. How do you trace your application so that you can see your trace messages in the output window?
    1. Use Console.WriteLine().
    2. Use tracelistener to add the output window and use trace.write.
    3. Debug.WriteLine().
    4. Output.WriteLine().
  4. You are creating an application where you have an if statement and an else statement. In the if statement, you have two conditions. You want both of these conditions to be validated before executing the code block. How do you achieve this?
    1. Use the && operator.
    2. Use the & operator.
    3. Use the | operator.
    4. User the || operator.
  1. How do you return a default value into a variable when your expression returns a null value?
    1. Use the ternary operator.
    2. Use the binary operator.
    3. Use the conditional OR.
    4. Use the null coalescing operator.
  2. You have multiple versions of the same method in your code. Your customer has requested you to make sure that all dependent applications use a specific version of the method. How do you make sure that no one invokes any other methods which may cause other exceptions?
    1. Change the access modifiers for all other methods.
    2. Throw an exception from these methods.
    3. Use the Obsolete attribute to let users know the correct method to use.
    4. All of the above.
  3. You are creating a C# application where you need to output multiple lines with a line break between them. How do you achieve this?
    1. var sb = new StringBuilder();sb.AppendLine(Line1); sb.AppendLine(Environment.NewLine); 
    2. var sb = new StringBuilder();foreach(string line in strList){sb.AppendLine(Line1); sb.AppendLine(Environment.NewLine); }
    3. var sb = new StringBuilder();sb.Append(Line1); sb.Append(' ');
    4. All of the above
  4. How would you make sure a parent class method is not accessible in inherited classes? Which access modifier would you use?
    1. Private
    2. Internal
    3. Protected
    4. Abstract 
  5. Specify the code to load an assembly at runtime:
    1. Assembly.Load()
    2. Assembly.Create("A1.dll");Assembly.Load();
    3. Assembly.Load("a.dll");
    4. Assembly.GetType().Load();
  1. When you create a C# console application, which files do you see in the solution explorer?
    1. Project, App.Config, Program.cs, Solution, Properties, and References
    2. App.Config, Program.cs
    3. Project, App.Config, Program.cs, Solution, Properties
    4. App.Config, Program.cs, Properties
  2. When you create a console application and change the static Main(string[] args) to static main(string[] args), what will happen?
    1. A compile-time error is raised.
    2. A runtime error is raised.
    3. Both a and b.
    4. None of the above.
  3. A class or a class member that is declared as internal can only be accessed by classes in the same assembly but not by outside assemblies. 
    1. True
    2. False
  4. Consider the following statements. Statement 1: A value type maintains the address of the variable. Statement 2: Two reference type variables pointing at address 1 reflect the updated value.
    1. Both are true.
    2. Statement 1 is true, statement 2 is false.
    3. Statement 1 is false, statement 2 is true.
    4. Both are false.
  5. While defining an interface, it is good practice to have access modifiers for the methods.
    1. True
    2. False
  6. How do you define an optional parameter?
    1. void AddNumbers(int a=1, int b)
    2. void AddNumbers(int a, int b  optional)
    3. void AddNumbers(int a, int b=4)
    4. void Add numbers(int a, optional int b)

  1. What is the keyword that you use in a program function where you are using a pointer declaration?
    1. Sealed
    2. Safe
    3. Internal 
    4. Unsafe
  2. What syntax do we use to append text to a file?
    1. File.CreateText
    2. FileInfo.Create
    3. File.Create
    4. File.AppendText
  3. Which collection type can be used to create a strongly typed, zero-based index to process objects in a FIFO manner?
    1. Queue<T>
    2.  List<T>
    3.  Array
    4.  Dictionary
  4. You are creating an application that manages information. You define a save method in the class and you want to ensure that only this class and any inherited classes can invoke the method. You want to define the save method as a strongly typed method. How do you achieve this?
    1. public static void Save<T>(T target) where T : new(), ParentClass {}
    2. public static void Save<T>(T target) where T : ParentClass,new() {}
    3. public static void Save<T>(T target) where T : ParentClass {}
    4. public static void Save(ParentClass target)  {}
  5. You are developing an assembly that will be used by multiple applications. You need to install it in GAC. Which actions would you perform to achieve this?
    1.  Sign the assembly and use the Gacutil tool to install the assembly in GAC.
    2.  Version assembly and use the Regsvr32 tool to install the assembly in GAC.
    3.  Drag and drop to the Windows assembly folder.
    4.  All of the above.

  1. When two parties need to communicate using the asymmetric algorithm, which key do they need to share?
    1. Private key
    2. Public key
    3. Both
    4. None 

 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.229.111