free geoip Common .Net Interview Questions - Jayson's Blog - jaysonKnight.com
jaysonKnight.com
Welcome to my corner of the internet

Common .Net Interview Questions

Here is a list of some common questions I ask potential candidates when screening for interviews (and no, I don't expect answers as in depth as I've listed here):

What are some of the objects exposed by the .NET framework that lend themselves to asynchronous method invocation, and what are a few ways architecturally to use these objects? What is the name of the interface used primarily as a way to check on an asynchronous method call?

The simplest way to execute a method asynchronously is to start it with BeginInvoke, do some work on the main thread, and then call EndInvoke. EndInvoke does not return until the asynchronous call completes. This is a good technique to use with file or network operations, but because it blocks on EndInvoke, you should not use it from threads that service the user interface.
Waiting on a WaitHandle is a common thread synchronization technique. You can obtain a WaitHandle using the AsyncWaitHandle property of the IAsyncResult returned by BeginInvoke. The WaitHandle is signaled when the asynchronous call completes, and you can wait for it by calling its WaitOne. If you use a WaitHandle, you can perform additional processing after the asynchronous call completes, but before you retrieve the results by calling EndInvoke. Bear in mind that the call to EndInvoke will block the calling thread unless the asnychronous method call has completed.
You can use the boolean IsCompleted property of the IAsyncResult returned by BeginInvoke to discover when the asynchronous call completes. You might do this when making the asynchronous call from a thread that services the user interface. Polling for completion allows the user interface thread to continue processing user input, thus this is the preferred way for a GUI to call an method asynchronously.
If the thread that initiates the asynchronous call does not need to process the results, you can execute a callback method when the call completes. The callback method is executed on a ThreadPool thread. To use a callback method, you must pass BeginInvoke an AsyncCallback delegate representing the method. You can also pass an object containing information to be used by the callback method. For example, you might pass the delegate that was used to initiate the call, so the callback method can call EndInvoke. If a callback has been specified on the BeginInvoke, it will be called when the target method returns. In the callback, the EndInvoke method is used to obtain the return value and the in/out parameters. If the callback was not specified on the BeginInvoke, then EndInvoke can be used on the original thread that submitted a request.
Name a design pattern you've used on a regular basis, and explain why you've used it and how it lent itself to accomplishing the programming task you were trying to accomplish. (there are numerous answers, if they name one and can talk about it for a minute or 2, that should suffice). Common ones will be Singleton, Factory, Observer, Asynchronous, Disposable, and Controller.

What are the similarities/differences between interfaces and abstract classes? When and why would use either one, and name a specific instance when you would use one and not the other?

Interfaces support multiple inheritance, whereas you can only inherit from one abstract class.
Abstract classes support partial to full implementation, whereas interfaces only define a contract with no implementation.
If you anticipate creating multiple versions of your component, create an abstract class. Abstract classes provide a simple and easy way to version your components. By updating the base class, all inheriting classes are automatically updated with the change. Interfaces, on the other hand, cannot be changed once created. If a new version of an interface is required, you must create a whole new interface.
If the functionality you are creating will be useful across a wide range of disparate objects, use an interface. Abstract classes should be used primarily for objects that are closely related, whereas interfaces are best suited for providing common functionality to unrelated classes.
If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class.
If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members.


What are 2 ways to facilitate the passing of objects across application domains via reflection? IE, there are 2 seperate programming constructs that can be used to enable objects to passed across application domains, a default class by itself cannot be passed across app domains. HINT: one is an attribute, the other is a base class.

You can mark the object with the Serializable attribute. Bear in mind that this will in turn make each and every member of the class serializable as well. If you need to implement partial serialization, inherit from ISerializable and just serialize the members you need to...or use the NonSerializable attribute on those members. An object that is serialized across application domains is done so as a copy of the object (similar to ByValue), so this can be an expensive proposition with larger objects.
If you inherit from MarshalByRefObject, you will get the same desired end result, however instead of a copy of the object being transported to the remote application domain, a proxy will be created that facilitates communication between the objects. When an object derives from MarshalByRefObject, an object reference will be passed from one application domain to another, rather than the object itself.


What are the 2 transport protocols that can be used in .NET remoting? What are the 2 transport payload types? What network scenarios are each combination best suited for?

SOAP payload via HTTP protocol. The HTTP channel uses the SOAP formatter by default and hence can be used in scenarios where clients will access the objects over the Internet. Since this approach uses HTTP, accessing .NET objects remotely through a firewall is enabled by this configuration. Objects exposed in this way can easily be configured as Web Services Objects simply by hosting these objects in IIS. Clients can then read the WSDL files of these objects to communicate with the Remote object using SOAP. There is an associated performance hit as SOAP payloads are quite a bit larger than their binary counterparts.
Binary payload via TCP protocol. The TCP Channel uses the binary formatter by default. This formatter serializes the data in binary form and uses raw sockets to transmit data across the network. This method is ideal if your object is deployed in a closed environment within the confines of a firewall. This approach is more optimized since it uses sockets to communicate binary data between objects. Using the TCP channel to expose your object gives you the advantage of low overhead in closed environments. This approach cannot be used over the Internet because of firewall and configuration issues.

Last one...what are some of the key fundamental differences between C# and VB.NET?

VB.NET doesn't support operator overloading.
C# is case sensitive.
C# instrinsically supports code comment sheets via XML tags.
You can write unsafe (C/C++ style) code in C# code blocks.
More explicit casting is necessary when writing in C#.
VB.NET supports optional parameters.
In VB.NET, parameters are passed by reference by default, whereas in C# parameters are passed by value.
Method level vars must be initialized in C# (even if it's with a null type), whereas in VB.NET there is some leniency with this.
VB.NET supports the With [typeName] construct, allowing for multiple actions to be performed on a type in one block.
VB.NET does not support unsigned numeric primitives.
VB.NET supports re-allocating an array (ReDim).

Nothing too too complicated, but i feel they are .NET fundamentals.  Comments are welcome!


Posted Nov 20 2003, 12:09 AM by Jayson Knight

12 Comments

Rupam wrote re: Common .Net Interview Questions
on 11-09-2004 11:15 AM
The questions are very good can u pl send in questions that are related to the practical work seneario
Thanks
Regards
Rupam
Gov wrote re: Common .Net Interview Questions
on 11-16-2004 4:31 PM
Really it is useful but some of 'em sound too complicated
R.SANJAY DAVID wrote re: Common .Net Interview Questions
on 11-17-2004 5:02 PM
WHAT IS THE DIFFERENCE BETWEEN EXISTING
.NET FRAMEWORK COMPONENTS

EX SYSTEM.DATA.DLL

AND

COMPONENTS AND USERCONTROLS THAT WE HAVE CREATED

jayson knight wrote re: Common .Net Interview Questions
on 11-27-2004 1:18 AM
@ Rupam: Look for a new post on this soon, though I've used most of the questions listed here on a daily basis in .Net development.

@ Gov: I don't consider these too complicated at all; most of these are fundamental to good design in .Net development.

@ R.SANJAY DAVID: Fundamentally, an assembly is an assembly regardless of who wrote it. System.Data is an assembly written by MS that ships with the .Net framework. Hypothetically you could roll your own version of this DLL by using ODBC, or you can extend the current implementation by inheriting from the base classes in this assembly. If you'd like to poke around the assemblies that ship with .Net, you can either use ILDASM, or Lutz Roeder's .Net Reflector add in (just google Lutz Roeder Reflector, I highly recommend this tool for any developers toolbox). If you are feeling even more adventurous, you can download the SSCLI (aka Roter...google Microsoft Rotor for more info), which is the source code for the ECMA spec of C# (includes the compiler; most notable part of Rotor is Remoting IMO as it's written entirely in C#). You can also have a look at the Mono project (google ximian mono) to see what the OSS folks are doing with .Net. Feel free to ping me if you have any other questions.
kiran wrote re: Common .Net Interview Questions
on 12-20-2004 10:20 AM
hi i m really impressd by u r idea .
can u please send some of the qusetions to me at kiran@donasy.com thanks in adv
·What is the GAC? What problem does it solve? wrote Querie
on 03-05-2005 10:19 AM
I need Answers
shals wrote re: Common .Net Interview Questions
on 03-22-2005 3:33 PM
hi these seems to be good,but if you could pls post Question on Asp.net and .net related to internet technologies.
thanks in advance
if possible post me on shalinsb@gmail.com
protected virtual void jaysonBlog { wrote Best of JaysonKnight.com -- Happy New Year!
on 12-30-2005 1:38 AM
One thing that really bugs me about blogs is that it’s still really damn hard to find specific...
Neelam wrote re: Common .Net Interview Questions
on 05-09-2006 2:45 AM
questions r really very good.
can u send me mor questions like these advance questions
my mail id is

gupta83_neelam@yahoo.com
Ashok wrote re: Common .Net Interview Questions
on 08-01-2006 6:27 AM

The questions are good. Would appreciate more such questions (and of course answers) on ASP.NET

More .Net interview Questions and Answers wrote re: Common .Net Interview Questions
on 05-19-2008 11:00 AM

Thanks for good questions.

Find more .Net Interview Questions with Answers At

<a target="_blank" href="www.techbaba.com/.../.net+question+answers.aspx">  New Dot Net Interview Faqs questions & answers</a>

Milano wrote re: Common .Net Interview Questions
on 06-04-2008 4:43 AM

Great blog. Thanks.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

Copyright © :: JaysonKnight.com
External Content © :: Respective Authors

Terms of Service/Privacy Policy