Reader and server admin Cypren passes along these answers to the first few sections of the .NET Interview Questions I linked to a couple of days ago.


Everyone who writes code

Describe the difference between a Thread and a Process?
--- Both are individual execution paths, but process timeslicing (and memory space) is enforced by the OS, while thread differentiation is enforced by applications.

What is a Windows Service and how does its lifecycle differ from a "standard" EXE?
--- Services are loaded by the operating system and run in contained process spaces detatched from user interaction; users logging on and off the system have no impact on them.

What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?
--- Windows processes are allowed 4GB of virtual address space, regardless of the actual amount of memory on the machine. Windows x64 allows 16TB of address space.

What is the difference between an EXE and a DLL?
--- EXEs can be launched as processes by the operating system. DLL executable code must be invoked by an existing process.

What is strong-typing versus weak-typing? Which is preferred? Why?
--- Strong-typing refers to defining the specific type of a reference at compile time rather than at run time. This results in more efficient execution and memory optimizations at compile time, as well as reduces the chance of a programmer accidentally providing a value of a type another component wasn't expecting.

Corillian's product is a "Component Container." Name at least 3 component containers that ship now with the Windows Server Family.
--- Component containers implement the IContainer interface to wrap components, providing a meta-architecture for organizing, interacting and communicating with the components.

What is a PID? How is it useful when troubleshooting a system?
--- (Ambiguous) This could refer to either a Microsoft Product ID -- the unique key that brands each activatable component installed on a system -- or to a Process ID, which is a means of referring to a specific process in calls to the Windows API.

How many processes can listen on a single TCP/IP port?
--- One.

What is the GAC? What problem does it solve?
--- The Global Assembly Cache. It stores strongly-named assemblies in a single location, allowing for verification of code library uniqueness when executing.

Mid-Level .NET Developer

Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming.
--- Object-oriented programming consists of defining programming structures around logical units of data and the functionality required to operate on them. Interface-oriented programming extends upon the concept by mandating that cross-dependencies between objects be expressed in the form of abstracted, defined guidelines (without specific implementation) so that objects have set expectations for touchpoints. Aspect-oriented programming proceeds one step further, defining certain "first tier" processes which apply to almost all objects (such as logging), and providing high level means of attaching functionality to a wide swath of objects without specific implementation required in each one.

Describe what an Interface is and how it’s different from a Class.
--- Interfaces are "guidelines without implementation" for functionality in an object. They define methods and properties which must be exposed, but leave it to the individual object to determine implementation.

What is Reflection?
--- Reflection is the ability to dynamically execute code without pre-linking at compile time. This may take the form of dynamic module loading and late binding, or it may take the form of real-time code construction and compilation.

What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?
--- Web services are generally stateless, using a standard HTTP interface, while remoting is highly customizable and extensible, varying by the specific application that uses it.

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

Conceptually, what is the difference between early-binding and late-binding?
--- Early binding determines execution path at compilation, late binding allows for dynamic execution at runtime.

Is using Assembly.Load a static reference or dynamic reference?
--- Dynamic

When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate?
--- When your assembly is not in the GAC.

What is an Asssembly Qualified Name? Is it a filename? How is it different?
--- A type reference qualified by the name of the assembly it is referenced from.

Is this valid? Assembly.Load("foo.dll");
--- No. Assembly.Load(string) takes the full name of the assembly (as contained in the GAC), not the name of the file.

How is a strongly-named assembly different from one that isn’t strongly-named?
--- Strongly-named assemblies can be loaded into the GAC and use key pairs to insure non-collision and authorship verification.

Can DateTimes be null?
--- No. They are structs, not objects.

What is the JIT? What is NGEN? What are limitations and benefits of each?
--- JIT is Just-in-Time compiling, which natively compiles .NET code as it needs to be executed, allowing more flexibility in platform optimization. NGEN is the Native Image Generator, a tool which precompiles native code for assemblies and caches it for execution, pre-empting JIT. NGEN saves time at execution in exchange for potentially slowing execution on platforms other than the one it was originally executed for.

How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization?
--- The garbage collector defines objects into multiple generations based upon their expected lifecycle, and collects each generation with different frequency. Non-deterministic finalization means that the Finalize() method of objects is not guaranteed to be called as soon as the object falls out of scope; it is executed when the garbage collector has time to prioritize it.

What is the difference between Finalize() and Dispose()?
--- Finalize() is called by the garbage collector before destroying an object, allowing it to clean up resources it may have allocated. Dispose() is a method the programmer can call on an object to force resource deallocation (and pre-empt costly finalization).

How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?
--- The using() construct allows you to mark a resource which is guaranteed to be disposed when the block exits. IDisposable provides an interface for the Dispose() method, which allows a programmer to forcibly finalize an object while still placing a Finalize() method in it as a means of security in case another programmer neglects to use Dispose().

What does this useful command line do? tasklist /m "mscor*"
--- Allows you to see which processes currently running have loaded a specific library -- in this case, anything beginning with "MSCOR".

What is the difference between in-proc and out-of-proc?
--- In-process communication is that between threads in a particular application space, as defined by the operating system. Out-of-process communication is that between non-shared memory and process spaces.

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

When you’re running a component within ASP.NET, what process is it running within on Windows XP? Windows 2000? Windows 2003?
--- XP & 2003: aspnet_wp.exe, 2000: inetinfo.exe

Senior Developers/Architects

What’s wrong with a line like this? DateTime.Parse(myString);
--- Doesn't specify a locale or format.

What are PDBs? Where must they be located for debugging to work?
--- Program Database files. They contain references that connect the uncompiled code to the compiled code for debugging. They must be located either in the same place as the EXE/DLL, or in your VS.NET specified symbols path.
---
What is cyclomatic complexity and why is it important?
--- It's a measure of the number of independent linearly executed paths through a program. It's important for judging the complexity of software and assisting in determinations of which modules should be refactored into smaller components.

Write a standard lock() plus “double check” to create a critical section around a variable access.

--- bool notLocked = true;

--- if (notLocked)
--- {
--- --- lock (typeof(lockingObject))
--- --- {
--- --- --- if (notLocked)
--- --- --- {
--- --- --- --- notLocked = false;
--- --- --- --- foo = lockingObject;
--- --- --- --- notLocked = true;
--- --- --- }
--- --- }
--- }

What is FullTrust? Do GAC’ed assemblies have FullTrust?
--- FullTrust means all .NET security permissions are granted to the assembly. GAC assemblies have FullTrust by default, but that can be changed by the user's security policy.

What benefit does your code receive if you decorate it with attributes demanding specific Security permissions?
--- Allows administrators to see exactly which permissions your application needs to run; prevents your code from being exploited beyond what permissions it absolutely needs; allows your application to forcibly fail instead of having to manually handle situations where it might be denied permissions it requires.

What does this do? gacutil /l | find /i "Corillian"
--- Lists all assemblies in the GAC, searching for those whose names contain "Corillian".

What does this do? sn -t foo.dll
--- Shows the token for foo.dll.

What ports must be open for DCOM over a firewall? What is the purpose of Port 135?
--- 135 for the service control manager, 1024-65535 (or whatever range the administrator has restricted DCOM to) for applications.

Contrast OOP and SOA. What are tenets of each?
--- OOP tries to encapsulate functionality required to operate on data with the data structure itself, making objects "self-reliant". SOA aims to decouple functionality from data entirely, using interfaces to allow functional components to operate blindly with as little understanding of the precise nature of the data they're fed as possible, allowing many types of data sets to be fed into them for the same operation.

How does the XmlSerializer work? What ACL permissions does a process using it require?
--- Reflects the object and reads its interfaces to serialize them. Requires the .NET ReflectionPermission, obviously.

Why is catch(Exception) almost always a bad idea?
--- Because it swallows an exception without doing anything with it. The only time this should really be used is when trying risky casts that you expect to have a reasonable likelihood of failure, but always of a very specific type.

What is the difference between Debug.Write and Trace.Write? When should each be used?
--- Debug.Write isn't compiled in if the project isn't built with the DEBUG symbol. Trace.Write calls are compiled regardless.

What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?
--- Release builds don't contain debug symbols and are more compact and optimized.

Does JITting occur per-assembly or per-method? How does this affect the working set?
--- Per-method. This affects the working set because methods that aren't lined up for calls aren't loaded, reducing its footprint.

Contrast the use of an abstract base class against an interface?
--- Abstract classes can provide implementations for methods and properties. Interfaces only provide required declarations.

What is the difference between a.Equals(b) and a == b?
--- The first uses the object's equivalency constructor to see if it considers itself value-equal to the the second object. The second construct compares their memory references to determine if they are the SAME object.

In the context of a comparison, what is object identity versus object equivalence?
--- Identity means that two references point to the same memory address. Equivalence means that two objects share the same value.

How would one do a deep copy in .NET?
--- Implement the IClonable interface, and define your implementation to execute deep copies on your subobjects (possibly through IClonable interfaces). Alternatively, serialize the object and then deserialize it into another object, but this is very slow compared to a dedicated cloning interface.

Explain current thinking around IClonable.
--- IClonable is preferable to using copy constructors because it is standardized and utilized by other portions of the .NET framework to generate object copies.

What is boxing?
--- Taking a value type and converting it to an object reference. Unboxing is the reverse process.

Is string a value type or a reference type?
--- It's an "illusionary value type" that masks an interface to the System.String reference type.

What is the significance of the "PropertySpecified" pattern used by the XmlSerializer? What problem does it attempt to solve?
--- Defines the specific parameters that .NET class members serialize into. Solves the issue of an XML spec needing to have slightly different names for class members than the class itself does.

Why are out parameters a bad idea in .NET? Are they?
--- Out parameters create uncertainty about the data which may be returned from the function, and permit the caller to potentially pass bad references which your function must validate before using. From a design standpoint, it's more elegant to define a custom class with multiple properties in the event that you need to return multiple values from a single function.

Can attributes be placed on specific parameters to a method? Why is this useful?
--- Yes. This might be needed to specify remoting implementations or types for method parameters, or to provide metadata for method parameters when exporting a code library.

C# Component Developers

Juxtapose the use of override with new. What is shadowing?
--- Override redefines an inherited method which was marked as virtual or abstract, and its access level must be the same as the method it overrides. New allows you to completely hide an inherited member and create a different implementation of it with whatever attributes you choose. Shadowing is another name for disabling an inherited method and redefining it.

Explain the use of virtual, sealed, override, and abstract.
--- Virtual marks a method as overridable. Sealed marks a class as uninheritable. Override redefines a method declared as virtual. Abstract defines a class which cannot be instantiated, or a method which must be overriden in any derived classes.

Explain the importance and use of each component of this string: Foo.Bar, Version=2.0.205.0, Culture=neutral, PublicKeyToken=593777ae2d274679d
--- Assembly name -- used for loading. Assembly version -- also used for loading. Culture -- defines culture settings used for string translation and other locale-specific settings. PublicKeyToken -- used to uniquely identify this assembly and prevent collisions.

Explain the differences between public, protected, private and internal.
--- Public: accessible from any class. Private: accessible only from within the same class. Protected: like private, but derived classes may also access. Internal: like public, but accessible only by code within the same assembly.

What benefit do you get from using a Primary Interop Assembly (PIA)?
--- A PIA is a strongly-named assembly which defines COM interfaces for a component. Because it is strongly-named, it can be loaded into the GAC and verified against the COM component's own signature to give the component collision-protection and authorship-verification benefits when interacing with .NET code.

By what mechanism does NUnit know what methods to test?
--- Reading attributes defined for classes and methods via reflection.

What is the difference between: catch(Exception e){throw e;} and catch(Exception e){throw;}
--- Both statements will catch and throw exception, but the latter will preserve the original exception stack.
---
What is the difference between typeof(foo) and myFoo.GetType()?
--- The first returns the object's type at compile time; the second returns it at runtime.
---
Explain what’s happening in the first constructor: public class c{ public c(string a) : this() {;}; public c() {;} } How is this construct useful?
--- The first constructor invokes the base constructor in addition to its own functionality; this would be useful if your base initialized basic field values or had other code that all other constructors would utilize.

What is this? Can this be used within a static method?
--- The "this" reference refers to the current object context. Static methods have no context, so it is not valid.

Comments

Supporters

Email blogmasterofnoneATgmailDOTcom for text link and key word rates.

Site Info

Support