Complex technical interview

1. Simplify the following code:

void foo (boolean a, boolean b, boolean c ) {
if ( a ) {
if ( b ) {
if ( !c );
else {

2. Two numbers are selected at random and without replacement from the set {1, 2, 3, 4, and 5}.

What is the probability that both the selected numbers are less than 4?

3. Explain the difference between an Interface and an Abstract class.

4. Explain the purpose of garbage collection in Java. When is it used?

5. Explain “pass by reference” and “pass by value”.

6. Explain the differences between HashMap, Map, and HashTable.

7. Explain the differences between Vector, ArrayList, and LinkedList. When would you use each?

8. What is the difference between a constructor and a method?

9. What is an Iterator?

10. You are given an array containing both positive and negative integers. Write a routine in Java to find the sub-array with the largest sum. Performance should be O(N).

11. You are given an array of size N in which every number is between 1 and N. Write a routine in Java to determine if there are any duplicates in the original array. You are allowed to destroy the array if you like.

12. Write a routine in Java to draw a circle without making use of any floating point
computations like sqrt. The formula for a circle is x**2 + y**2 = r**2.

13. Given only putchar, write a routine putlong that prints out an unsigned long in decimal. Note that you cannot use sprintf, itoa, etc.

14. Write a one-line Java expression to test whether a number is a power of 2.

15. Given an array of characters that form a sentence of words, write an efficient algorithm to reverse the order of the words (not the characters) in the array.

16. How many locations are there on the Earth where by walking one mile south, one mile east and one mile north you reach the place where you started? Give your logic.

17. Give a very good method to count the number of ones in an “n-bit” (e.g. 32-bit) number.

18. What are the major factors that determine the performance of a sorting algorithm? Give an example of an algorithm with performance O(N**2), one with performance O(NlogN), and one with performance O(N).

19. It takes George 1 hour to paint a certain room. It takes Peter 2.5 hours to paint the same room.
How long would it take George and Peter to paint the room if they worked together and in no way interfered with each other? Show your logic.

20. Assume that planet Earth has a circumference of 40,000 kilometers. Assume you have a string encircling the Earth at its equator. If 1 meter were added to the length of that string and you were to again encircle the Earth’s equator with the string, what would be the gap between the surface of the Earth and the string? Show your calculation.

21. What is synchronization in respect to multithreading?

Vélemény, hozzászólás?

Adatok megadása vagy bejelentkezés valamelyik ikonnal: Logo

Hozzászólhat a felhasználói fiók használatával. Kilépés / Módosítás )

Twitter kép

Hozzászólhat a Twitter felhasználói fiók használatával. Kilépés / Módosítás )

Facebook kép

Hozzászólhat a Facebook felhasználói fiók használatával. Kilépés / Módosítás )

Google+ kép

Hozzászólhat a Google+ felhasználói fiók használatával. Kilépés / Módosítás )

Kapcsolódás: %s