.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…
- Interface-oriented programming means defining and working strictly through interfaces.
- 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.
- When using early-binding the call information is known at compile time.
- 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.
- The Assembly Qualified Name contains the assembly name, version and public key token and thus allows
- 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.
- Strongly-named assemblies are signed using a privatepublic key pair which helps with code verification.
- 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.
- JIT means Just In Time compilation which means the code is being compiled just before it is supposed to run.
- 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.
- It divides the objects into three generations.
- 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.
- The using statement defines a scope at the end of which a given object will be disposed.
- 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.