Tuesday, June 26, 2012

Interview Questions

1. What is the role of index in a database?
Ans: http://stackoverflow.com/questions/1108/how-does-database-indexing-work
2. What is multithreading?
3. How does a server handle multiple parallel requests from several clients?
Ans: http://stackoverflow.com/questions/8278887/how-does-a-server-handle-web-service-requests-from-multiple-clients
4. What is a hash table?
4. What is load factor in hash table?
Ans: http://en.wikipedia.org/wiki/Hash_table#Load_factor
5. What is a singleton (class)?
Ans: http://codeofdoom.com/wordpress/2008/04/20/how-and-when-to-use-singleton-classes/
6. What would happen if you allocate a huge amount of memory and free it repeatedly?
Ans: Data fragmentation
7. What is const cast?
8. What is a binary search tree?
9. How would you traverse a binary search tree?
10. What are datastructures?
11. What are the features of a Object Oriented Programing?
Ans: http://en.wikipedia.org/wiki/Object-oriented_programming#Fundamental_features_and_concepts
12. What is polymorphism?
13. What is persistent data?
Ans: A transient class is a class whose objects will not be saved on disk between sessions. For an object to be saved (i.e. to exist beyond the end of the curent session), the class must be declared persistent.
14. What is abstraction?
15. What is decomposition?
16. What is a smart pointer?
17. What is a virtual function?
18. What are templates?

Quiz:
Q. You have 2 ropes, "A" & "B" and they both burn in 1 hr. You have a matchbox. How will you determine 45min?
Ans. Burn "A" from both sides, and "B" from one side. "A" will burn completely in 1/2 hr (30 min). As soon as "A" finishes, burn the other end of "B". "B" will now burn completely in 15 min. So you have 45 min.

Q. You have 9 balls, 8 of them are identical and only 1 is heavier than the rest. You have a beam balance. How will you separate the heavier one in the least number of measurements.
Ans. Divide 9 balls in groups of 3 => 3(A), 3(B), 3(C). Weigh two groups, e.g. "A" & "B". If both are same, the heavier is in "C" group. If "B" is heavier, heavier ball is in "B". Take the group containing tthe heavier ball ("B" or "C"). Divide it in groups of 3 => 1(E), 1(F), 1(G). Weigh two groups e.g. "E" & "F".  If both are same "G" is the heavier ball. If "F" is heavier, "F" is the heavier ball and vice versa. So least number of required weightings = 2.

No comments:

Post a Comment