Sunday, November 28, 2010

Java interview questions for Hadoop developer Part 1

Since Hadoop and all its eco-system is built in java hence when hiring for a hadoop developer it makes sense to test the core java skills of the interviewee as well. Following are some questions that I have compiled that test the basic java understanding of the candidate. I would expect any decent candidate to answer 90% of these questions

Q1. What is mutable object and immutable object
If a object value is changeable then we can call it as Mutable object. (Ex., StringBuffer) If you are not allowed to change the value of an object, it is immutable object. (Ex., String, Integer, Float)

Q2. What are wrapped classes in Java. Why do they exist. Give examples 
Wrapped classes are classes that allow primitive types to be accessed as objects, e.g. Integer, Float etc

Q3. Even though garbage collection cleans memory, why can't it guarantee that a program will run out of memory? Give an example of a case when garbage collection will run out ot memory 
Because it is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection. Once example can be if yuo try to load a very big file into an array.

Q4. What is the difference between Process and Thread? 
A process can contain multiple threads. In most multithreading operating systems, a process gets its own memory address space; a thread doesn't. Threads typically share the heap belonging to their parent process. For instance, a JVM runs in a single process in the host O/S. Threads in the JVM share the heap belonging to that process; that's why several threads may access the same object. Typically, even though they share a common heap, threads have their own stack space. This is how one thread's invocation of a method is kept separate from another's

Q5. How can you write a indefinate loop in java 
while(true) {
for ( ; ; ){

Q6. How can you create singleton class in Java 
Make the constructor of the class private and provide a static method to get instance of the class

Q7. What do keywords "this" and "super" do in Java 
"this" is used to refer to current object. "super" is used to refer to the class extended by the current class

Q8. What are access specifiers in java. List all of them. Access specifiers are used to define score of variables in Java. There are four levels of access specifiers in java- public
- private
- protected
- default

Q9. Which of the following 3 object oriented principals does access specifiers implement in java
- Encapsulation
- Polymorphism
- Intheritance 


Q10. What is method overriding and method overloading 
With overriding, you change the method behavior for a subclass class. Overloading involves having a method with the same name within the class with different signature


  1. Thanks - The articles on your blog are definatly helpful. I found another blog from your blog that is pretty good.