1. Question: What is the problem with the following function, which is supposed to convert a Stream into byte array?
    public static byte[] ReadFully(Stream input)
    {
        using (MemoryStream ms = new MemoryStream())
        {
            input.CopyTo(ms);
            return ms.ToArray();
        }
    }

    A
    It will work only in .NET Framework 4 or above, as the CopyTo function of the memory stream is available only in .NET Framework 4 or later versions.

    B
    It will work only in .NET Framework 3.5 or below, as the CopyTo function of the memory stream is available only in .NET Framework 3.5 or earlier versions.

    C
    It will work in all versions of the .NET framework.

    D
    None of these.

    Note: Not available
    1. Report
  2. Question: Which of the following functions are used to wait for a thread to terminate?

    A
    Wait()

    B
    Terminate()

    C
    Join()

    D
    Abort()

    Note: Not available
    1. Report
  3. Question: ______ helped overcome the DLL conflict faced by the C# language versions prior to .NET.

    A
    CLR

    B
    JIT

    C
    CTS

    D
    GAC

    E
    Satellite Assemblies

    F
    All of these

    Note: Not available
    1. Report
  4. Question: What is the benefit of using a finally{} block with a try-catch statement in C#?

    A
    The finally block is always executed before the thread is aborted.

    B
    The finally block is never executed before the thread is aborted.

    C
    The finally block is never executed after the thread is aborted.

    D
    The finally block is always executed before the thread is started.

    Note: Not available
    1. Report
  5. Question: In which of the following namespaces is the Assembly class defined?

    A
    System.Assembly

    B
    System.Reflection

    C
    System.Collections

    D
    System.Object

    Note: Not available
    1. Report
  6. Question: Which of the following statements is true regarding predicate delegates in C#?

    A
    Predicate delegates are used for filtering arrays.

    B
    Predicate delegates are references to functions that return true or false.

    C
    Predicate delegates are only used in System.Array and System.Collections.Generic.List classes.

    D
    Predicate delegates are only used in ConvertAll and ForEach methods.

    Note: Not available
    1. Report
  7. Question: Working with a list of Employees:
    List<Employee> lstEmployees = new List<Employee>
                {
                    new Employee{Name="Harry",Age=15},
                    new Employee{Name="Peter",Age=22},
                    new Employee{Name="John",Age=45},
                    new Employee{Name="Harry",Age=15},
                    new Employee{Name="Peter",Age=22},
                    new Employee{Name="John",Age=45},
    
                };
    It is required to filter out employees having distinct names. Which one of the following options cannot be used?

    A
    public class Employee { public int Age { get; set; } public string Name { get; set; } public override bool Equals(object obj) { return this.Name.Equals(((Employee)obj).Name); } public override int GetHashCode() { return this.Name.GetHashCode(); } } List<Employee> distinctEmployeesByName = lstEmployees.Distinct().ToList();

    B
    public class Employee { public int Age { get; set; } public string Name { get; set; } } public class EmployeeEquityComparable : IEqualityComparer<Employee> { #region IEqualityComparer<Employee> Members public bool Equals(Employee x, Employee y) { return x.Name.Equals(y.Name); } public int GetHashCode(Employee obj) { return obj.Name.GetHashCode(); } #endregion } List<Employee> distinctEmployeesByName = lstEmployees.Distinct(new EmployeeEquityComparable()).ToList();

    C
    public class Employee:IEqualityComparer<Employee> { public int Age { get; set; } public string Name { get; set; } #region IEqualityComparer<Employee> Members public bool Equals(Employee x, Employee y) { return x.Name.Equals(y.Name); } public int GetHashCode(Employee obj) { return obj.Name.GetHashCode(); } #endregion } List<Employee> distinctEmployeesByName = lstEmployees.Distinct().ToList();

    D
    public class Employee { public int Age { get; set; } public string Name { get; set; } } List<Employee> distinctEmployeesByName = (from emp in lstEmployees group emp by emp.Name into gemp select gemp.First()).ToList();

    Note: Not available
    1. Report
  8. Question: What are the benefits of using the ExpandoObject class over a using dictionary?

    A
    It offers easier data binding from XAML.

    B
    It's interoperable with dynamic languages, which will be expecting DLR properties rather than dictionary entries.

    C
    WPF data binding will understand dynamic properties, so WPF controls can bind to an ExpandoObject more readily than a dictionary.

    D
    ExpandoObject can help in creating complex hierarchical objects. ExpandoObject implements the INotifyPropertyChanged interface, which gives more control over properties than a dictionary.

    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){
                int @int = 15;
                Console.WriteLine(@int);
                Console.ReadLine();
    }

    A
    15

    B
    It will throw a compilation error.

    C
    It will throw an error at runtime.

    D
    @15

    Note: Not available
    1. Report
  10. Question: What is the purpose of the catch block in the following code?
    try { 
        // Code that might throw exceptions of different types 
    }
    catch { 
        // Code goes here 
    }

    A
    Only errors of type std::unexpected are caught here.

    B
    Other code exceptions are caught.

    C
    This catch block must be the first one in a series of catch blocks that may or may not be followed.

    D
    This catch block can be the last one in a series of catch blocks to handle any exception which is not handled by the preceding catch blocks, each of which handles an exception of a particular type.

    E
    No errors are caught in this try block (they are all passed to the next closest catch).

    F
    None of these.

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