Home > .NET Framework > Scott Hanselman’s interview questions – Mid-Level .NET Developer

Scott Hanselman’s interview questions – Mid-Level .NET Developer

Answers to Mid-Level .NET Developer
  1. Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming.

    Interface Oriented: I do not think this is a standard term, I may be wrong. This is a part of Component Oriented Programming. Components interact through well defined interfaces or contracts. COM world had so much of emphasis on Interfaces. .NET instead of interfaces uses metadata to exchange the contract.

    Object Oriented Programming: A programming methodology which models software in the natural way as they are represented in the real world objects. The core tenets are Abstraction, Encapsultation, Polymorphism and Inheritance. This took reuse to a newer level.

    Aspect-oriented Programming: A programming methodology which is complimentary to OOP when it comes to handling cross cutting concerns. Cross cutting concerns mean, features which are common across all the components / classes / applications. An example would be transactions or security. Every component / class / application needs transactions and security. Instead of every class / method in every application implementing this, this should be done in one and only place. Security, Transactions, Logging are examples of such cross cutting concerns. MTS was one of the examples of this, Role based security, Transactions cross cutting concerns were provided by the container (MTS). Usually this is achieved by interception.

  2. Describe what an Interface is and how it’s different from a Class.

    An interface defines a contract. It doesn’t provide an implementation. A class can and usually provides an implmentation. May be Abstract Base class vs Interface is also worth looking into
    Interface vs Abstract Base Class

  3. What is Reflection?

    Reflection is the technology by which one can dynamically query / emit / use type and assembly information. An example should help. For example if you are writing a factory method which should instantiate and return an object. How do you make your factory load assemblies and instantiate types which are not known to it? The answer is reflection.

  4. What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?

    Remoting assumes the other end is .NET. This is because .NET remoting using SOAP uses the SoapFormatter to serialize data. SoapFormatter embeds the type information required to deserialize the object into the message itself. This requires that the client and the server must have access to this assembly. Remoting believes in the .NET Type System. Remoting believes in sharing types and assemblies. Remoting can support DCOM style Client Activated Objects which are stateful. The use of CAOs though have to be carefully thought about because CAOs cannot be load balanced. ASMX model does not assume that the other end is .NET. ASMX uses XmlSerializer to serialize data. Xmlserailizer believes that the XML Type System, that is the XSD is superior and works on serializing data conforming to a schema. In other words XML Web Services believe in sharing schema and contracts over types and assemblies. This makes the Web Services interoperable. ASMX services are usually stateless.

  5. Are the type system represented by XmlSchema and the CLS isomorphic?

    No. There is some impedence mismtach. That’s the reason you need IXmlSerializable to help the XmlSerializer. XSD is not a type system in the traditional sense as per Steve Maine, read more here. http://hyperthink.net/blog/CommentView,guid,1c407222-5849-4fd0-a026-341633859105.aspx
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondatatypesupportbetweenxsdtypesnetframeworktypes.asp
    http://weblogs.asp.net/cazzu/archive/2004/02/20/WxsTypeSystem.aspx

  6. Conceptually, what is the difference between early-binding and late-binding?

    If the resolution of what implemenation of a method is going to get called happens at compile time, then Early. If the binding to the method implementation happens at runtime then it is late binding. Ex: Type.InvokeMember

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

    Dynamic. The compiler records static references in the assembly manifest’s metadata at build time. Dynamic references are constructed on the fly as a result of calling various methods, such as System.Reflection.Assembly.Load.

    http://msdn2.microsoft.com/en-us/library/yx7xezcf.aspx

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

    This calls for a separate entry 😉

    http://sendhil.spaces.live.com/blog/cns!30862CF919BD131A!578.entry

  9. What is an Asssembly Qualified Name? Is it a filename? How is it different?

    May be he means the four part logical assembly name here. File Name of the File containing the manifest without Extension, Public Key Token, Culture, Version. Filename is a the physical file name in the filesystem.

  10. Is this valid? Assembly.Load("foo.dll"); ?

    No. Load takes a logical 4 part assembly name, not the filesystem path.

  11. How is a strongly-named assembly different from one that isn’t strongly-named?

    A strong name ensures that the assembly name is unique (Since the public key / public key token are cryptographically unique).
    A strongly named assembly helps in tamper proof verification
    More information can be found here
    A strongly named assembly helps one to avoid Dll hell through the versioning policy applied

  12. Can DateTimes be null?

    No. DateTime is a value type cannot be null.

  13. What is the JIT? What is NGEN? What are limitations and benefits of each?

    .NET Assemblies contain IL. This IL is compiled to machine code when a method is called the first time by a Just in Time (JIT) Compiler. Jitting reduces the working set. Jitting means there is a performance impact for the first time the a method is called. This performance impact can be negated by using NGEN. NGEN is used to generate native image during the deployment. (As opposed to first access). The negative here is that NGEN results in a larger Working Set (If most of your methods are never going to get called).
    More stuff about NGEN can be found here

  14. How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization?

    Nobody discusses this better than Jeffrey
    Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework
    Garbage Collection—Part 2: Automatic Memory Management in the Microsoft .NET Framework

  15. What is the difference between Finalize() and Dispose()?

    Finalize is a protected method on the object class, which you class can override if it has to do cleanup of unmanaged resources. Dispose is the only method on IDisposable which you implement if you class can implement if it has to do cleanup of unmanaged resources. Why two APIs which do the same thing. For that you need to understand the difference between Finalize and Dispose. Finalize is called by the CLR after a GC. Dispose is called by the client developer of a component. Since Finalize is called after a GC, CLR has to keep an object alive minimum past 1 GC cycle. This promotes the object by a generation (which may be unnecessary if your object is short lived). Finalization is non-deterministic. Whereas Dispose is determisnitstic cleanup of unmanaged resources. Then why bother with Finalize if Dispose is better? What if the developer forgets to call Dispose. Then the unmanaged resource will be left hanging. Just in case the developer forgets to call Dispose, Finalize kicks in and cleans it up after the a GC. But if the developer calls Dispose, its better to suppress the Finalize call from the CLR, by calling GC.SuppressFinalize(this) in Dispose. To Summarize this the recommended cleanup pattern for any class using unmanaged resources: 1) Implement IDisposable as well as override Finalize. 2) In Finalize call GC.SuppressFinalize(this);
    public class SqlConnection : IDisposable, IDbConnection
    {
        private void Cleanup()
        {
            // Release unmanaged resource
        }

        public void Dispose()
        {
            Cleanup();
            GC.SuppressFinalize(this);
        }

        protected override void Finalize()
        {
            Cleanup();
        }
    }

  16. What does this useful command line do? tasklist /m "mscor*" ?

    Lists all the processes which has loaded CLR.

  17. What is the difference between in-proc and out-of-proc?

    In-Proc: Loaded in the same process space as of the host process. Out-Proc: Loaded in a different process space from the host process. Any faults in In-Proc component might bring down the host. The host will be unafected by any faults in the out-of-proc component. Out-Proc components have a performance overhead associated, since we cross process boundaries.

  18. What technology enables out-of-proc communication in .NET?

    .NET Remoting. cross app domain communication 😉

  19. When you’re running a component within ASP.NET, what process is it running within on Windows XP? Windows 2000? Windows 2003?

    XP, 2000 – aspnet_wp.exe
    2003 – w3wp.exe

Categories: .NET Framework
  1. Unknown
    October 25, 2006 at 1:02 pm

    Cross App Domain need not be out-of-proc

  2. Unknown
    November 23, 2008 at 10:06 am

    您需要二手液晶显示屏、废旧液晶屏么?我们是不折不扣的二手液晶屏、旧液晶屏大批发商,长期大量供应可再利用的旧液晶屏。我公司提供的各种尺寸的二手液晶屏, 不同厚薄如笔记本屏,均已经过我们严格的分类,检验,测试流程。请访问协力液晶屏www.sceondhandlcd.com[bbibbbjbbjgjfhac]

  3. Unknown
    May 15, 2009 at 10:57 am

    Hi,Great blog with interesting informations. I can use it t solve my problem.ThanxM.http://www.vanjobb.hu/

  4. Jason
    November 5, 2009 at 7:22 am

    Just in case you are interested in excellent quality and reasonable price replica watches, please contact us via our website http://www.progiftstore.com/.

  5. Jason
    December 2, 2009 at 7:30 am

    At http://www.progiftstore.com/ you can get the best quality swiss replica watches with the lowest price, in progiftstore, you can buy replica watches with a great discount.

  6. Unknown
  7. Unknown
  8. November 11, 2011 at 12:13 am

    Hey, nice site. Do you do anything else for WordPress sites?

  9. June 13, 2013 at 2:46 pm

    Some of the good questions shared here for interview, I think you should have post some basic questions too as they are asked too. People generally at the time of interview prepares for high level but the are unaware of simple basics and they are even failed due to not knowing the basics.

  1. November 19, 2010 at 11:01 pm

Leave a comment