Google
 

Wednesday, April 23, 2008

Interview Questions

.NET


  1. How is it determined that variable is reference type or value type? Is it hard coded?

  2. Can value type also has methods just as reference types? Ans: Yes

  3. Can new keyword (operator) be used with value types?
    Ans: Yes. The new operator cannot be overloaded.
    If the new operator fails to allocate memory, it throws the exception, OutOfMemoryException.

  4. How can garbage collector call Finalize method though it is always protected?
    Ans: Uses reflector.


  5. How to tell GC not to move an object from one generation to next?


    Ans: Use fixed statement. The fixed statement prevents the garbage collector from relocating a movable variable. The fixed statement is only permitted in an unsafe context. Fixed can also be used to create fixed size buffers. The fixed statement sets a pointer to a managed variable and "pins" that variable during the execution of statement. Without fixed, pointers to movable managed variables would be of little use since garbage collection could relocate the variables unpredictably. The C# compiler only lets you assign a pointer to a managed variable in a fixed statement.

    // assume class
    // pt is a managed variable, subject to garbage collection.
    Point pt = new Point();
    // Using fixed allows the address of pt members to be
    // taken, and "pins" pt so it isn't relocated.
    fixed ( int* p = &pt.x ) { *p = 1; }

  6. How to call Grand Pa version of a method (virtual) from a grand child class?

  7. Difference between static & singleton class.

  8. How singleton class's static member instance() be remoted (static members can not be remoted).

  9. Is using Assembly.Load a static reference or dynamic reference?

  10. When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate?

  11. Explain volatile keyword.

    Ans: The volatile keyword indicates that a field might be modified by multiple concurrently executing threads. Fields that are declared volatile are not subject to compiler optimizations that assume access by a single thread. This ensures that the most up-to-date value is present in the field at all times. The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock Statement (C# Reference) statement to serialize access. The volatile keyword can be applied to these types:

    • Reference types.

    • Pointer types (in an unsafe context).

    • Integral types such as sbyte, byte, short, ushort, int, uint, char, float, and bool.

    • An enum type with an integral base type.

    • Generic type parameters known to be reference types.

    • IntPtr and UIntPtr.

    The type in question must be the field of a class or struct. Local variables cannot be declared volatile.


  12. A page has 5 links each pointing to a jpg file. When clicking over a link it should display picture with a string added to that dynamically. How to do that? Hint: iHttpHandler

  13. What is view state? Can view state store objects like dataset? Hint: Yes it can store dataset but not recommended.

  14. Can view state be stored as plain text instead of encrypted text?

No comments: