.NET interview questions from Scott Hanselman – Answers (Part 2)

Here are my answers to the second part of the questions (without using MSDNGoogleetc. except when noted):

Mid-Level .NET Developer

  • Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming.
    • Interface-oriented programming means defining and working strictly through interfaces.
      Object-oriented programming means defining defining a program using relationships between objects a classes (inheritance, polymorphism etc.)
      I’ve heard the buzz about AOP (aspect-oriented programming) but I have yet to study what exactly does it mean…
  • Describe what an Interface is and how it’s different from a Class.
    • An interface defines a contract without implementation. A class implements an interface.
  • What is Reflection?
    • Reflection is used to query .NET assemblies and types for information. It can also be used to create type instances, invoke methods and even emit .NET code at runtime (Reflection.Emit).
  • What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?
    • I’ve never used .NET remoting but I assume the difference is that remoting is not as interoperable as web services.
  • Are the type system represented by XmlSchema and the CLS isomorphic?
    • No.
  • Conceptually, what is the difference between early-binding and late-binding?
    • When using early-binding the call information is known at compile time.
      When using late-binding the call information is only known at runtime.
  • Is using Assembly.Load a static reference or dynamic reference?
    • Dynamic reference.
  • When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate?
    • For loading assemblies from given file or folder (such as plugins etc).
  • What is an Asssembly Qualified Name? Is it a filename? How is it different?
    • The Assembly Qualified Name contains the assembly name, version and public key token and thus allows
      versioning and singing as opposed to a simple filename.
  • Is this valid? Assembly.Load(“foo.dll”);
    • No because “foo.dll” is not an assembly qualified name.
  • How is a strongly-named assembly different from one that isn’t strongly-named?
    • Strongly-named assemblies are signed using a privatepublic key pair which helps with code verification.
      signed assemblies could be placed in thee GAC.
  • Can DateTimes be null?
    • No because it is a structure and not a class.
  • What is the JIT? What is NGEN? What are limitations and benefits of each?
    • JIT means Just In Time compilation which means the code is being compiled just before it is supposed to run.
      This means longer startup time (because the code takes some time to compile) but more efficient compilation (since the compiler has more information about the target system etc.).
      NGen is used to pre-JIT code which yields faster startup time but the compiler produces less efficient code because it has less information.
  • How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization?
    • It divides the objects into three generations.
      The first generation is used for short lived objects and is collected often (its cheap to collect it).
      The other two generations are used for longer term object.
      Non-deterministic finalization means that it is not known when the object’s finalizer is called since it is called when the GC decides to collect the object and not when the object falls out of scope etc.
  • What is the difference between Finalize() and Dispose()?
    • Finalize() is called by the runtime (the GC) and Dispose() is called by the user.
  • How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?
    • The using statement defines a scope at the end of which a given object will be disposed.
      Using the ‘using statement’ helps not to forget disposing of a disposable object.
      IDisposable is an interface used to define a way to dispose of objects in a deterministic manner.
      When the ‘using statement’ scope ends the Dispose() method is automatically called on the given object.
  • What does this useful command line do? tasklist /m “mscor*”
    • It shows all the processes that loaded a DLL with a name matching the given pattern. In this case we will see all the processes using the .NET framework.
  • What is the difference between in-proc and out-of-proc?
    • out-of-proc requires marshaling between two processes and thus slower.
  • What technology enables out-of-proc communication in .NET?
    • Remoting.
  • When you’re running a component within ASP.NET, what process is it running within on Windows XP? Windows 2000? Windows 2003?
    • The ASP.NET worker process.

You may also like...

6 Responses

  1. John says:

    I learned more from the way you answered the questions, but the answers did confirm things I knew. During an interview, when I get the gitters, I am too verbose and ramble on… When I do ramble on it is a dead give away that I don’t know what I am talking about, while at other times I will elaborate to make up for that which I didn’t know. An example was a recent answer to a question of what an abstract class is. In addition to answering the question, I felt compelled to continue on by explaining both types of inheritance C# supports. Ugh! Your answers are specific and I also like how you answered a couple by simply saying you don’t know, or have not worked with that technology. Just thought I would mention this and many thanks!

  2. ekampf says:

    Hi John,
    Thanks for the comment.
    The most important thing in an interview is to be confident and honest. If you don’t know or not sure about an answer, just say so.
    Showing common sense and ability\interest in learning is just as important (or even more) than plain trivia knowledge..


  3. apoc29 says:

    Hi Eran,

    Thank you very much for this article. I really learned a lot. I will be having a tech. interview next week for a .NET dev position. Wish me luck =) I will keep on reading your other posts. Thanks!

  4. Srinivas says:

    The interface vs class answer should be clarified a bit. While correct that an interface is a contract, a class doesnt necessarily implement an interface, or anything at all. Abstract classes can function simlarly to interfaces and provide no implementation.

  5. lax says:

    hi friends, i wld like to learn .net thru internet,can any one help me in giving good project with code and everything pls

  6. Dhiraj says:

    Aspect oriented identifes the aspects of a
    program – separates out what’s essential(functionality
    wise) and what’s repetitive(or not so essential from
    functionality perspective).