1. Question: Which of the following code samples will check if a file is in use?

    A
    protected virtual bool IsFileLocked(FileInfo file) { FileStream stream = null; try { stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None); } catch (IOException) { return true; } finally { if (stream != null) stream.Close(); } return false; }

    B
    try { using (Stream stream = new FileStream("MyFilename.txt", FileMode.Open)) { } } catch { }

    C
    internal static bool FileOrDirectoryExists(string name) { return (Directory.Exists(name) || File.Exists(name)) }

    D
    FileInfo file = new FileInfo("file.txt"); if (file.Exists) { // TO DO }

    Note: Not available
    1. Report
  2. Question: Which of the following statements is true regarding the code samples below? A: try { // code goes here } catch (Exception e) { throw e; } B: try { // code goes here } catch (Exception e) { throw; }

    A
    A will lose the call stack trace information. B will preserve the call stack trace information.

    B
    A will preserve the call stack trace information. B will lose the call stack trace information.

    C
    Both A and B will preserve the call stack trace information.

    D
    Both A and B will lose the call stack trace information.

    Note: Not available
    1. Report
  3. Question: Which of the following is the correct way to implement deep copying of an object in C#?

    A
    By using the System.Runtime.Serialization.Formatters.Binary.BinaryFormatter class.

    B
    By using the System.Reflection.DeepCopy class.

    C
    By using the DeepCopy() method of Object class.

    D
    By using the MemberwiseClone() method of Object class.

    Note: Not available
    1. Report
  4. Question: What will be the output of the following Main program in a C# console application (Assume required namespaces are included)?
    static void Main(string[] args)
    {
        string Invalid = "$am$it$";
        string sResult = Invalid.Trim(new char[]{'$'});
        Console.WriteLine(sResult);
        Console.ReadLine();
    }

    A
    amit

    B
    am@am$

    C
    $am$it$

    D
    am$it

    Note: Not available
    1. Report
  5. Question: Which of the following is the correct way to perform a LINQ query on a DataTable object?

    A
    var results = from myRow in myDataTable where results.Field("RowNo") == 1 select results;

    B
    var results = from myRow in myDataTable.AsEnumerable() where myRow.Field("RowNo") == 1 select myRow;

    C
    var results = from myRow in myDataTable.Rows where myRow.Field<int>("RowNo") == 1 select myRow;

    D
    var results = from myRow in myDataTable.AsEnumerable() where myRow.Field<int>("RowNo") == 1 select new { IID= myRow.Field<int>("IID"), Date = myRow.Field<DateTime>("Date"), };

    Note: Not available
    1. Report
  6. Question: What is the purpose of the vshost.exe file in Visual Studio?

    A
    It is used to improve the performance of the Visual Studio debugger.

    B
    It is used to improve the performance of Visual Studio plugins.

    C
    It is used to improve the performance of the C# compiler.

    D
    It is used to load Visual Studio configuration data.

    Note: Not available
    1. Report
  7. Question: Which of the following code snippets for catch shows a better way of handling an exception? 1. catch (Exception exc) { throw exc; } 2. catch (Exception exc) { throw; }

    A
    1 is better as it maintains the call stack.

    B
    2 is better as it maintains the call stack.

    C
    Both are same.

    D
    None of these.

    Note: Not available
    1. Report
  8. Question: What will be the value of result after these two statements? int num1 = 10, num2 = 9; int result = num1 ^ num2;

    A
    1

    B
    8

    C
    9

    D
    10

    E
    109

    F
    3

    Note: Not available
    1. Report
  9. Question: What will be the output of the following Main program in a C# console application (Assume required namespaces are included)?
    static void Main(string[] args)
    {
    string sPrint = String.Format("{{ My name is bond. }}");
    Console.WriteLine(sPrint);
    Console.ReadLine();
    }

    A
    {{ My name is bond. }}

    B
    It will throw a compilation error.

    C
    { My name is bond. }

    D
    It will throw a runtime error.

    Note: Not available
    1. Report
  10. Question: What is the difference between data types "System.String" and "string" in C#?

    A
    string is a value type, while System.String is a reference type.

    B
    There is no difference,string is just an alias of the System.String data type.

    C
    string variable is limited to storing alphabetic characters, while System.String does not have any limit.

    D
    None of these.

    Note: Not available
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd