There are three different types of what you would label as "technical questions". First, you have the straightforward, purely technical type of questions. For example:
- What is multiple inheritance?
- Describe Polymorphism.
- What are partial classes in C#?
- What are mock objects?
- What are delegates in C#?
- How do you implement multi-threaded applications in Java?
Of course, depending on your answer, you may expect follow-up questions like: What can go wrong with multiple inheritance? How can you go around it in Java?
![]() |
http://dilbert.com/strips/comic/2003-11-27/ |
The second type of questions is supposed to test your problem-solving skills. At the end of the day, you might be able to answer all the theory questions above ('A' students should all do), but you might not necessarily know how to actually use these concepts in problem solving (not all 'A' students can). Here are a few examples from very recent interviews:
Q1. You have a singly-linked list. You do not have access to its head, but you do have a pointer to one of its items. How would go about removing that item from the list?
- The trick here is to understand what is 'exactly' needed. Many interviewees will quickly jump to thinking about how to delete the node that contains the item. Of course you will not be able to do that if you do not have a pointer to the previous node (or at least the head). Otherwise, you will break the linkage in the list. So what do you do? Shift the items one by one to overwrite the item you want to delete and then remove the node at the end of the list.
Q2. How would you model a Chicken in Java?
- Surprisingly enough, this question does not seem to get old. I used this example in one of my software engineering lectures. The next lecture, one of my students told me that she got the same exact question in her interview on that very day! She was very lucky.
There is really no one correct answer to this question. All you need to do is ask questions to understand what qualifies as attributes of the Chicken class (e.g. weight, age, body parts... etc) and what kind of behavior is expected (i.e. member functions like layEgg(), cluck(), getSlaughteredAndGrilledOnMyNewBBQ() .. sounds cruel I know. But be careful here not to do too much in one function. Maybe you should define one function to slaughter and another to grill).
Q3. In an unsorted array of integers, we have the numbers from 1 to 100 stored except for one number. How do you find that number?
- If the array is sorted, it is a simple traversal to check for arr[i+1]-arr[i] != 1.
- If the array is not sorted, then you can add up all the elements and use the mathematical formula to compute the missing element (The sum of the numbers from 1 to N is N * (N+1) /2)
- You can also use a HashTable to find the missing element unless the question specifies that you can't.
Q4. Without using a loop, how do you check if all the characters composing a string are the same? For example "11111" or "bbb"? You can use any built-in string method.
- Substring the given string from the first character until the one before the last. Then substring starting from the second character until the last. Check if the two substrings match.
s.substring(0,s.length()-1).equals(s.substring(1,s.length()))
- Take the first char. Use the replace all method and make sure the result string is empty.
s.replaceAll(s.charAt(0)+"", "")
- You can always use recursion if the question did not specify that you can't.
- If the language provides support for simple conversion, convert the string into an array, and the array into a set. Check that the produced set has only one element.
Q5. How do you efficiently remove duplicate elements from an array/list?
- You need to avoid using any algorithm that is O(n2) or more.
- Put them in a set and put them back in the array/list.
- The question gets very interesting when there are more constraints like not allowing extra storage, maintaining the order of the elements, not allowing sets.. etc.
Good luck!
Our recruiters share some of the weirdest questions candidates have been asked that were not remotely related to the roles they were interviewing for. Here are the top 10 most ridiculous questions that employers have asked.
ReplyDelete