Tuesday, 26 July 2011

C# Interview questions -- part 1

I had a couple of interviews a few weeks ago and I thought I would share the technical questions that I was asked here.

I was not really impressed at being asked theoretical questions about object oriented programming, perhaps because I struggled with the answers, not because I did not know what the concepts were, or how to use them, but because I couldn't recall what they were called, I'm looking at you encapsulation. You might be reading this and thinking he doesn't have a clue, and you'd be right, but think about it like this. You don't need to know what method overloading is actually called, you just need to know that can have methods with the same name as long as you change something , e.g. number or order of arguments or return type, at any rate. Rant over, let's get on with it.

Can you explain what a class is? Class
Can you explain what encapsulation is?  Encapsulation
Can you explain what inheritance is? Inheritance
Can you explain what a design pattern is? Design Pattern
Can you explain what Database normalization is? Database normalization

Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". This is straight from this post.

Write a program that prints the reverses the words for the following sentence "the quick brown fox jumps over the lazy dog".

Write a program that prints the fibonacci sequence (i.e. 1,1,2,3,5,8 ...):
  1. Any method is available (i.e. use recursion)
  2. Do not use recursion.
I know it is possible to do step 2, I have done it, see below, but in a interview situation, I simply could not do it.

   1         public static long fibiter(long number)
   2         {
   3             long fTerm = 0, sTerm = 1;
   4                         
   5             for (int i = 0; i < number; ++i)
   6             {
   7                 long temp = fTerm;
   8                 fTerm = sTerm;
   9                 sTerm += temp;
  10             }
  11                         
  12             return fTerm;
  13 
  14         }

No comments:

Post a Comment