Some basic (but effective) .NET interview questions
I’ve been interviewing many .NET development developers lately and one of the most surprising things is that many candidates, both junior and senior level, cannot correctly answer questions which I consider very basic. I compile a short list of such questions below, hopefully it maybe helpful for you as interviewees or interviewers.
- What is the difference between
System.Int32type andinttype? I receive “interesting” answers like:System.Int32is reference type whileintis a value type, orSystem.Int32is presented in 4 bytes whileintonly needs 2 bytes. The correct answer is that there is no difference between them, they are alias. - What is the purpose of the method
GetHashCode()inSystem.Objectclass? Some candidates just cannot even guess what this method do. I’m not sure how they can properly use dictionary types without even knowing what the purpose of this method is. - Can you assign
nullvalue to a struct? Some confirm that they can (after I ask a few more questions to make sure that they are not referring to nullable types). - How does the modifier
readonlyaffect reference types? A few say that you cannot modify the fields of thereadonlyinstance. In fact, the only effect is that you cannot change the address inside that reference (i.e. assign it to another object). - Is this code valid
public const object KEY = new object()? Many, especially those with the Java background, say they do not see any problem with it. In fact, that code does not compile since, unlikereadonly, expressions assigned to “const” fields must be evaluatable at compile time. - Do you need to have a
catchblock whenever you use thetryblock? Some people just forget about thetry...finally...pattern. As a side note, I’ve seen a developer who used thecatchblock just to re-throw the caught exception in order to use thefinallyblock (since the poor guy thought that he could not usefinallywithout having thecatchblock). - How can you make a class serializable (for .NET Remoting)? Some thinks classes are made serializable by default. Of course they are not, you need to either annotate the class with the
Serializableattribute or implement theISerializableinterface. - What is the accessibility level of
internal protectedfields and methods? Some say these fields and methods can only be access by subclasses within the same assembly. Some others even tell me they do not think it is possible to combine these two modifiers. The right answer is these fields and methods can be accessed either by subclasses (in any assembly) or classes within the same assembly (or “friend” assembly).
That’s it. A few simple questions but can filter out quite a good number of candidates. I’ll talk about more interesting (and difficult) questions next time.
Addendum 4/29/2007: as some commenters thought that these are the only questions I use to assess the interviewees’ capability, I think I should make it clear that these questions are only found interesting by me since they are quite basic yet many candidates fail to answer many of them – and they are not the only measure I use to assess the candidates.
If a candidate can answer correctly all these questions, it does not necessarily mean that s/he would be hired; on the other hand, if a candidate cannot get all of these correct, it does not necessarily mean that s/he would not be hired – it only means s/he does not have full-score for one area assessed during the interview.
There are more areas to be assessed (e.g. design skills, problem-solving skills, analytical and logical thinking, communication skills, quick-learning ability, and team-fitness etc.) before the hire/no-hire decision can be made. The acceptance score for each area depends on the position (junior or senior) the candidate is applying for (but usually I use my instinct instead of basing on a frozen set of scores).


By BREAKSTS penny stock