1. Question: Which of the following is true for CLR?

    A
    It is an interoperation between managed code, COM objects, and pre-existing DLL's (unmanaged code and data).

    B
    It is a software Output Unit of Deployment and a unit of versioning that contains MSIL code.

    C
    It is the primary building block of a .NET Framework application and a collection of functionality that is built, versioned, and deployed as a single implementation unit.

    D
    All of these.

    Note: Not available
    1. Report
  2. Question: In the sample code given below, which of the data members are accessible from class Y?
    class X {
        private int i;
        protected float f;
        public char c;
    }
    
    class Y : X { }

    A
    c

    B
    f

    C
    i

    D
    All of these

    Note: Not available
    1. Report
  3. Question: If i == 0, why is (i += i++) == 0 in C#?

    A
    source code i += i++; abstract syntax tree += i i (post) ++

    B
    First, i++ returns 0. Then i is incremented by 1. Lastly i is set to the initial value of i which is 0 plus the value i++ returned, which is zero too. 0 + 0 = 0.

    C
    int i = 0; i = i + i; i + 1;

    D
    int ++(ref int i) { int c = i; i = i + i; return c;}

    Note: Not available
    1. Report
  4. Question: Performance-wise, which of the following is the most efficient way to calculate the sum of integers stored in an object array?

    A
    int FindSum(object[] values) { int sum = 0; foreach (object o in values) { if (o is int) { int x = (int) o; sum += x; } } return sum; }

    B
    int FindSum (object[] values) { int sum = 0; foreach (object o in values) { int? x = o as int?; if (x.HasValue) { sum += x.Value; } } return sum; }

    C
    int FindSum (object[] values) { int sum = values.OfType<int>().Sum(); return sum; }

    D
    int FindSum (object[] values) { int sum = 0; foreach (object o in values) { if (o is int) { int x = Convert.ToInt32(o); sum += x; } } return sum; }

    Note: Not available
    1. Report
  5. Question: Consider the following code block:
    public class Person
    {
        public string GetAge()
        {
            lock (this)
            {
                // Code to get Age of this person object.
            }
        }
    }
    Which of the following statements is true?

    A
    lock(this) actually modifies the object passed as a parameter, and in some way makes it read-only or inaccessible.

    B
    lock(this) can be problematic if the instance can be accessed publicly, because code beyond one's control may lock on the object as well. This could create deadlock situations where two or more threads wait for the release of the same object.

    C
    lock(this) marks current object as a critical section by obtaining the mutual-exclusion lock for a given object, all private fields of the object become read-only.

    D
    Implement locking using current application instance or some private variable is absolutely the same and does not produce any synchronization issue, either technique can be used interchangeably.

    Note: Not available
    1. Report
  6. Question: The ______ namespace is not defined in the .NET class library.

    A
    System

    B
    System.CodeDom

    C
    System.IO

    D
    System.Thread

    E
    System.Text

    Note: Not available
    1. Report
  7. Question: Which of the following is true about constructors and member functions?

    A
    A constructor can return values, but a member function cannot.

    B
    A member function can declare and define values, but a constructor cannot.

    C
    A member function can return values, but a constructor cannot.

    D
    All of these.

    Note: Not available
    1. Report
  8. Question: Which of the following language code is not 'managed' by default in .NET framework?

    A
    Visual Basic

    B
    C#

    C
    C++

    D
    Jscript

    Note: Not available
    1. Report
  9. Question: There is a class that has a public int counter field that is accessed by multiple threads. This int is only incremented or decremented. To increment this field, three thread-safe approaches are mentioned below: A) lock(this.locker) this.counter++; B) Interlocked.Increment(ref this.counter); C) Change the access modifier of counter to public volatile Which statement is incorrect with regards to these approaches?

    A
    All 3 are equivalent and can be used interchangeably.

    B
    Though A is safe to do, it prevents any other threads from executing any other code which is guarded by locker.

    C
    B is the best approach as it effectively does the read, increment, and write in 'one hit' which can't be interrupted.

    D
    C on it's own isn't actually safe at all. The point of volatile is that multiple threads running on multiple CPU's can, and will, cache data and re-order instructions.

    Note: Not available
    1. Report
  10. Question: What will happen if the following code is compiled in .NET 4 or above (Assume required namespaces are included)?
    public class var { }
    public class main
    {
        public static void main(string[] args)
        {
            var testVar = new var();
        }
    }

    A
    This code will not compile, as var is a reserved keyword, so it can not be used as a class name.

    B
    This code will compile, as var is merely a contextual keyword and it is used to provide a specific meaning in the code, so it will cause no problems.

    C
    This code will not compile, as a new object cannot be created like var testVar = new var();

    D
    None of these.

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