Saturday, March 15, 2008

IT Job Interview Questions

A few of my ex-teammates and I prepared this when we were looking for jobs. C++ and general IT questions. Feel free to add answers below.
  1. What are enumerations?
  2. What are unions?
  3. What do you know about byte alignment in structs?
  4. How can you create objects on the heap?
  5. What are virtual classes?
  6. Find the number of 1's in a number.
  7. There is an array of numbers from 1 to 1000 in which one of the numbers is duplicated. Find the duplicated number.
  8. Create a queue using two stacks.
  9. Write a one-line check for checking whether a given number is a power of 2.
  10. Difference between new and malloc.
  11. What happens on mixing free and new?
  12. What is name mangling?
  13. What is the usage of volatile and mutable keywords?
  14. What happens when you delete a null pointer?
  15. How can you delete void*?
  16. Casting in C++
  17. Safe dynamic casting using static cast.
  18. Are static members allowed in a local class?
  19. What all do threads share?
  20. Difference between thread communication and process communication.
  21. How to construct a tree, given its traversals?
  22. What are smart pointers?
  23. What is Thread Local storage?
  24. How can you get to common ancestors of two nodes in a tree?
  25. What are named constructors?
  26. What is placement new?
  27. What is the difference between char* and char[]?
  28. Delete a node from a linked list, given the pointer to the node.
  29. For a good design, what all should be implemented in a C++ class? E.g. Copy constructor, assignment operator, etc.
  30. Should a constructor throw an exception?
  31. Should a destructor throw an exception?
  32. What are virtual destructors?
  33. Difference between Thread synchronization and process synchronization.
  34. Write code to detect loops in a list.
  35. How to find complexity of recursive functions?
  36. Named parameter idiom.
  37. Design patterns - singleton, factory, visitor, observer.

1 comments:

Vishnu said...

6.A.
Below is 'C' Program:
int getNoOfOnes(unsigned int n)
{
int count=0;
while(n!=0)
{
n=(n&(n-1));
count++;
}
return count;
}