Home > .NET, Management, Programming Languages > Some basic (but effective) .NET interview questions

Some basic (but effective) .NET interview questions

April 26th, 2007

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.Int32 type and int type? I receive “interesting” answers like: System.Int32 is reference type while int is a value type, or System.Int32 is presented in 4 bytes while int only 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() in System.Object class? 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 null value 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 readonly affect reference types? A few say that you cannot modify the fields of the readonly instance. 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, unlike readonly, expressions assigned to “const” fields must be evaluatable at compile time.
  • Do you need to have a catch block whenever you use the try block? Some people just forget about the try...finally... pattern. As a side note, I’ve seen a developer who used the catch block just to re-throw the caught exception in order to use the finally block (since the poor guy thought that he could not use finally without having the catch block).
  • 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 Serializable attribute or implement the ISerializable interface.
  • What is the accessibility level of internal protected fields 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).

Comments are closed.