The interview started with some SQL and database questions. I had tried to study some basic SQL stuff over the weekend, but I didn't think that they were going to ask me anything about it, I figured they would focus more on my C# experience. Since my experience with SQL and databases is very limited, I think its safe to say that I failed this part of the interview.
Next they moved on to some OOP (Object Oriented Programming) questions and I'm happy to say that I did much better in this sections. They asked me a few different questions on what inheritance was, when would you implement inheritance, and a few other questions. I struggled a bit on explaining myself, but I got through it.
Next was probably my favorite part, actual coding on a white board. They asked me how I would write a function that would calculate the factorial of a given number. This part I spent probably a couple of minutes since it was really straight forward. This is the code I wrote:
public static int Factorial(int n) { int result = 1; for (int i = n; i > 0; i--) result = result * i; return result; }
They looked at the code, and told me it was good. Then they asked me to rewrite the function using recursion. I struggled a bit on this part, I had trouble trying to put into code what I had already done in a different way. They gave me a hint saying that 5! = 5 * 4! and that was all I needed. Here is the code I wrote:
public static int FactorialRecursive(int n) { int current = n; if (n == 1) return n; int next = FactorialRecursive(n - 1); return current * next; }
Overall I think I did much better in the second part of the interview than the first. I am not too hopeful on getting the position, but at least now I know what I need to work on and I am ready for the future. That is all for now, thanks for reading!
No comments:
Post a Comment