Contents tagged with SQL Server

  • Technical Interview Questions

    I have been on some recent technical interviews for Tech Lead and/or Architect Roles. I am keeping track of the questions asked and will post them here.  The answers you see are mostly copy/paste from a Google search, with a mix of my own thoughts.  Feel free to jump in with your own questions and/or answers. 

    1.       define encapsulation

    a.       Data /Information hiding, hiding; objects do not reveal their attributes  and behaviors.  All interaction with an object should be done thru it’s interface.  

    b.      Storing data and functions in a single unit (class) is encapsulation. Data cannot be accessible to the outside world and only those functions which are stored in the class can access it.

    c.       The purpose is to achieve potential for change: the internal mechanisms of the component can be improved without impact on other components, or the component can be replaced with a different one that supports the same public interface. Encapsulation also protects the integrity of the component, by preventing users from setting the internal data of the component into an invalid or inconsistent state. Another benefit of encapsulation is that it reduces system complexity and thus increases robustness, by limiting the interdependencies between software components.

    2.       define abstraction

    a.       the act of representing essential features without including the background details or explanations.

    b.      reduce and factor out details so that one can focus on a few concepts at a time.

    3.       define garbage collection and what is meant by generational GC

    a.       The .NET Framework's garbage collector manages the allocation and release of memory for your application. Each time you use the new operator to create an object, the runtime allocates memory for the object from the managed heap. As long as address space is available in the managed heap, the runtime continues to allocate space for new objects. However, memory is not infinite. Eventually the garbage collector must perform a collection in order to free some memory. The garbage collector's optimizing engine determines the best time to perform a collection, based upon the allocations being made. When the garbage collector performs a collection, it checks for objects in the managed heap that are no longer being used by the application and performs the necessary operations to reclaim their memory.

    b.      The garbage collector keeps track of objects that have Finalize methods, using an internal structure called the finalization queue. Each time your application creates an object that has a Finalize method, the garbage collector places an entry in the finalization queue that points to that object. The finalization queue contains entries for all the objects in the managed heap that need to have their finalization code called before the garbage collector can reclaim their memory.

    c.       Generational collectors group objects by age and collect younger objects more often than older objects. When initialized, the managed heap contains no objects. All new objects added to the heap can be said to be in generation 0, until the heap gets filled up which invokes garbage collection. As most objects are short-lived, only a small percentage of young objects are likely to survive their first collection. Once an object survives the first garbage collection, it gets promoted to generation 1.Newer objects after GC can then be said to be in generation 0.The garbage collector gets invoked next only when the sub-heap of generation 0 gets filled up. All objects in generation 1 that survive get compacted and promoted to generation 2. All survivors in generation 0 also get compacted and promoted to generation 1. Generation 0 then contains no objects, but all newer objects after GC go into generation 0. Thus, as objects "mature" (survive multiple garbage collections) in their current generation, they are moved to the next older generation. Generation 2 is the maximum generation supported by the runtime's garbage collector. When future collections occur, any surviving objects currently in generation 2 simply stay in generation 2. Thus, dividing the heap into generations of objects and collecting and compacting younger generation objects improves the efficiency of the basic underlying garbage collection algorithm by reclaiming a significant amount of space from the heap and also being faster than if the collector had examined the objects in all generations.

                                                                   i.      The GC maintains lists of managed objects arranged in "generations." A generation is a measure of the relative lifetime of the objects in memory. The generation number indicates to which generation an object belongs. Recently created objects are stored in lower generations compared to those created earlier in the application's life cycle. Longer-lived objects get promoted to higher generations. Because applications tend to create many short-lived objects compared to relatively few long-lived objects, the GC runs much more frequently to clean up objects in the lower generations than in the higher ones.

    4.       define disposing in .NET

    a.       Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    5.       Define the difference between finalize and dispose in .NET

    a.       In general, the Dispose pattern is used to release unmanaged resources in a timely fashion. This allows you to do this in a deterministic fashion- in other words, you have control over when they are released. The Object.Finalize method is also used for the purpose of releasing resources - but it is non-deterministic. You have no control over when it will be called by the GC. Further, implementing a Finalize method can have an adverse affect on the performance of the GC because it takes two passes of the GC to collect objects that override Finalize.  So, in general, if you are using objects that manage unmanaged resources, such as database connections, you implement IDisposable AND override  Finalize. This way, your covered if the client fails to call Dispose - you know that your resources will then be released when the object is GC'd. Of course, one you call Dispose - you don't need the finalize method to be called by the GC and suffer an unnecessary performance hit.

    6.       xml tags and attributes



    7.       define soa

    a.       Service Oriented Architecture: putting enterprise functionality that rarely or never changes in the enterprise into a service that all enterprise applications can call into; typically a web service

    b.      SOA is the practice of sequestering the core business functions into independent services that don’t change frequently. These services are glorified functions that are called by one or more presentation programs. The presentation programs are volatile bits of software that present data to, and accept data from, various users.

    c.       At the highest level, SOA is nothing more (and nothing less) than separating changeable elements from unchangeable elements

    d.      SOA is not about any particular technology. Rather it is a design philosophy that decouples well heeled business functions from volatile processes and presentation

    8.       define soap


    9.       define serialization

    a.       the process of converting the state of an object into a form that can be persisted or transported. The complement of serialization is deserialization, which converts a stream into an object. Together, these processes allow data to be easily stored and transferred.

    b.      NET Framework features two serializing technologies:

                                                                   i.      Binary serialization preserves type fidelity, which is useful for preserving the state of an object between different invocations of an application. For example, you can share an object between different applications by serializing it to the Clipboard. You can serialize an object to a stream, to a disk, to memory, over the network, and so forth. Remoting uses serialization to pass objects "by value" from one computer or application domain to another.

                                                                 ii.      XML serialization serializes only public properties and fields and does not preserve type fidelity. This is useful when you want to provide or consume data without restricting the application that uses the data. Because XML is an open standard, it is an attractive choice for sharing data across the Web. SOAP is likewise an open standard, which makes it an attractive choice.

    10.   define DTO

    a.       Data Transfer Object; could be custom Business Objects, DataSets

    11.   Define marshalling

    a.       The process of gathering data and transforming it into a standard format before it is transmitted over a network so that the data can transcend network boundaries. In order for an object to be moved around a network, it must be converted into a data stream that corresponds with the packet structure of the network transfer protocol. This conversion is known as data marshalling. Data pieces are collected in a message buffer before they are marshaled. When the data is transmitted, the receiving computer converts the marshaled data back into an object.

    b.      Data marshalling is required when passing the output parameters of a program written in one language as input to a program written in another language.


    12.   Define interactions with business folks, selling your idea, coaching them, etc


    13.   define design patterns, give an example of 2


    14.   define Polymorphism

    a.       “Many Forms”.   The ability of a derived class to perform its own implementation of a parents  method thus re-defining the method.  It’s the ability to hide alternative implementations behind a common interface.


    15.   learn more about current web services, messaging, patterns, etc


    16.   What does the finalize method do and when to use it

    a.       allows an object to clean up its unmanaged resources properly when the garbage collector reclaims the memory used by the object

    b.      By default, the Finalize method does nothing. If you want the garbage collector to perform cleanup operations on your object before it reclaims the object's memory, you must override the Finalize method in your class

    c.       The unmanaged resources must be explicitly released once the application has finished using them. .Net Framework provides the Object.Finalize method: a method that the garbage collector must run on the object to clean up its unmanaged resources, prior to reclaiming the memory used up by the object. Since Finalize method does nothing, by default, this method must be overridden if explicit cleanup is required.

    d.      Finalize provides a backup to prevent resources from permanently leaking if the programmer fails to call Dispose

    17.   What is reflection and when would one use it

    a.       The ability to discover the composition of a type (e.g., class, interface, structure, enumeration, or delegate) at runtime.

    b.      The classes in the System.Reflection namespace, together with System.Type, allow you to obtain information about loaded assemblies and the types defined within them, such as classes, interfaces, and value types. You can also use reflection to create type instances at run time, and to invoke and access them.

    18.   Define AppDomains

    19.   Define Clustered Indexes in SQL Server



  • Getting SQL Joins

     I always have to stop and think about a SQL Join before using one. Call me dumb or maybe I just don't get it.  It's a block for me.