Sunday, May 12, 2013

Why is a manhole round?

This is a popular question that Microsoft asked prospective employees.

1. A round lid is easy to roll and move around.
2. By making it round the least amount of surface area and therefore material is used for the lid.
3. By being round there is more room for a worker to maneuver inside the manhole.

Wednesday, April 15, 2009

Another Interview

1. The Zune problem. That is wrong here is that an infinite loop happens when days = 366.

year = ORIGINYEAR; /* = 1980 */

while (days > 365)
{
if (IsLeapYear(year))
{
if (days > 366)
{
days -= 366;
year += 1;
}
}
else
{
days -= 365;
year += 1;
}
}

2. Write a reverse string method.

void ReverseString(char* str)
{
char temp = '';
int length = strlen(str);
for (int i = 0; i < length/2; i++)
{
temp = str[i];
str[i] = str[length-i-1];
str[length-i-1] = temp;
}
}

3. What does this code do
The answer is that it is strcmp

int foo(char* a, char*b)
{
int i;
for (i=0; a[i]==b[i]; i++)
{
if{str[i]== '\n')
{
return 0;
}
}
return a[i]-b[i];
}

Sunday, March 25, 2007

what is a factory and what is an abstract factory?

appearantly a factory is a class where you create classes at runtime. An abstract factory adds another level of abstraction where you get to create classes of different types at runtime...or at least thats the way I understand it.

Tuesday, August 29, 2006

Some differences between C# and C++

C# does not have any pointers.
C# does not have operator overloading.
C# has automatic garbage collection like java.
In C# struct is a value type and class is a reference type. ie; stucts cannot be treated like classes like they can in C++.

Finally, a job offer

Ok, so I finally got a job offer. The terms are not exactly what I was looking for but I am really tired of job hunting, so I'll take it. I am gonna keep this blog going though, adding more stuff to it every once in a while. I think I might need it again soon in the future.

Wednesday, August 23, 2006

Another interview

Here is what I was asked

  1. what is virtual inheritance?
  2. what is a singleton?
  3. what is a factory?
  4. why would you use the virtual key word on a function?
  5. what is explicit?(only useful for constructors with a single parameter)
  6. how would you reduce disc access in a program?
  7. difference between struct and class in C++ , in C#?
and some other questions that I forget.

Appearantly I have to go to a second none technical interview with them, and if I don't screw up, I'll get this job. The interviewer said they do an intensive background check, including checking your credit! Hopefully, these guys aren't flakes like threewave software who ask for your references, check them, ask for your salary expectations, and then don't give an offer.

Monday, August 21, 2006

Some Interesting Things In C++

I found out some interesting things when making this persistent file based order tracking system which I was asked to code before an interview.
  1. In a copy constructor, if your Object(const Object & rhs) is not declared as const, you get an error saying: "no copy constructor available or copy constructor is explicit". This happens on VS.Net professional 2003 and might happen on other compilers. Interesting, I never thought the a compiler will complain (specially with a misleading error message) for not declaring something as const.
  2. To make integral type member data as consts, you must declare them as static const.
  3. Related to 2. To make static integral member data (which are not const), you must define it outside the class in C++ and use the scope resolution operator on it.
  4. Related to 2 and 3 . To declare Non integral member data (such as arrays or strings) as consts you must do 2. AND you must define them outside of the class like 3.
  5. Summary: Related to 2, 3, and 4. Only static const integral types can be defined inside the class. Any consts members must be static const. Any static members (except for static const integral members) must be defined outside the class with the scope resolution operator.
  6. by making a const function, you are telling the compiler, that I am not gonna change the (this) object inside this function.
I wrote this shit down, because if I didn't I would forget them in about 10 minutes...

Friday, August 11, 2006

Stupid Interview Questions

Here is a funny, yet true article I found in Business Week Online about stupid interview questions that you can be asked. I have in fact had to answer some of these questions. I wish I had read this article before I had to answer these questions. Very funny stuff.

http://www.businessweek.com/careers/content/sep2005/ca20050921_1099_ca009.htm