1-844-696-6465 (US)        +91 77600 44484        help@dezyre.com

Top 50 Java Interview Questions for Hadoop Developers

Hiring managers agree that “Java is one of the most in-demand and essential skill for Hadoop jobs. But how do you get one of those hot java hadoop jobs? You have to ace those pesky java hadoop job interviews artfully. You might be going for Hadoop job interview but if you have previously worked on Java platform then the range of questions can be related to core java concepts and also other components in the Hadoop Ecosystem. To demonstrate your java and hadoop skills at an interview, preparation is vital. While we have a series of blogs that will help you prepare Hadoop Interview Questions for your next hadoop job interview-

Top 100 Hadoop Interview Questions and Answers 

Hadoop Developer Interview Questions at Top Tech Companies,

Top Hadoop Admin Interview Questions and Answers

Top 50 Hadoop Interview Questions

Hadoop HDFS Interview Questions and Answers

Hadoop Pig Interview Questions and Answers

Hadoop Hive Interview Questions and Answers

Hadoop MapReduce Interview Questions and Answers

Sqoop Interview Questions and Answers

HBase Interview Questions and Answers

This blog will help you prepare basic Java interview questions commonly asked during hadoop job interviews.

Java Interview Questions for Hadoop Developers

The best way to prepare for your Java Hadoop Developer job is to begin with a realistic java hadoop resume highlighting java and hadoop projects you have worked on in your past. Having prepared, a well-built java hadoop resume it is important to prepare the most commonly asked core java interview questions. We have listed some of the most commonly asked Java Interview Questions for a Hadoop Developer job role so that you can curate concise and relevant responses that match with the job skills and attributes, needed for the Java Hadoop Developer jobs. With these java interview questions for hadoop, you will be better prepared with the kind of interview questions asked for Java Hadoop Developer jobs that you might come across in your next hadoop job interview.

Want to know java hadoop developer salary ? CLICK HERE

Java Hadoop Interview Questions and Answers for 2016

  1. Which is the only variable that needs to be set in the conf/hadoop-env.sh file for hadoop MapReduce to work?

JAVA_HOME is the only variable that needs to be set and should point to the java installation directory.

  1. Which collection interface in Java is used to maintain unique elements?

Map interface in Java maps unique keys to values, given a key and value pair- the value is stored in the Map object which can be retrieved using the key.

  1. What platform and version of Java is required to work with Apache Hadoop?

The recommended java version to with Apache Hadoop is 1.6 or higher, preferred from Sun. Windows and Linux are the supported operating systems to work with Hadoop but Mac OS is famous for working with hadoop.

  1. What is the difference between a class variable and an instance variable in Java?

Class Variables only have a single copy of the variable and are declared with static modifiers. Every object of the class shares a single copy of the class variable, so if any changes are made to a class variable they will be seen by all the objects of a class. A class variable is allocated memory when the class is loaded first time.

Example of a Class Variable Declaration in Java

Public class Product {

    public static int Barcode;

}

Instance variables belong to an object and are specified without a static modifier. Every object of the class will have its own personal copy of the instance variable unlike class variables where single copy of the variable is shared by different objects of the class.

Example of an Instance Variable Declaration in Java

public class Product {

    public int Barcode;

}

Big Data and Hadoop Certification Training

If you would like more information about Big Data careers, please click the orange "Request Info" button on top of this page.

  1. How will you achieve multi-threading in Java?

Multithreading in Java can be achieved in two ways –

  • By defining a new class which implements the runnable interface. An object of that class is then passed to constructor method of Thread.
  • By defining a new class that extends the thread class.
  1.  What is the difference between an abstract class and interface?

Interface is different from an abstract class because interface is just a type that can be satisfied by a class which implements the interface. Interfaces in java help implement multiple inheritance because a class can extend only one other class.

Interface do not have any implementation and just are limited to constants and public methods whereas abstract class in java can have partial implementation along with static methods and protected access blocks. A class can extend only one abstract class but it can implement several interfaces.

  1. Can you explain the difference between path and classpath?

These are the operating system environment variables wherein PATH variable defines the system where executable files are present while CLASSPATH is used to specify the location of .class files.

  1. What is the return type of main () method in Java?

main () method in java does not return anything and hence is always declared as void.

  1. As we know that abstract class in Java cannot be instantiated, how will you use the non-static methods of an abstract class?

By extending the abstract class it is possible to use the non-static methods.

  1. Where can a protected method be accessed?

Any protected method can be accessed by all the classes of the same package and also by the subclass of the class in any other package.

  1. If I don’t want a class to be inherited, what should I do?

The class has to be declared as ‘final’ to ensure that it cannot be extended by any other class.

  1. Is java the only language for Hadoop jobs to be written?

It is not necessary to write Hadoop jobs in Java language, there are many other ways to write hadoop jobs using non-java codes. Hadoop Streaming allows hadoop map and reduce tasks to be written in the form of any executable script.

  1. Differentiate between Throw and Throws in Exception Handling.

Throw clause is used when a user wants to throw a customized explicit exception. Throw clause is used if there is a need for a specific exception to be thrown to the calling method.

try {

if (age>=100) {throw new AgeBarException (); //This is a customized exception

} else {

....}

}

} catch (AgeBarException ex) {

...code to handle Exception.....

}

Throws Clause lists all the exceptions that piece of code might throw. Throws clause provides a warning to the invoking method that these are the list of exceptions it might throw and all these need to be handled.

  • throws is used to declare an exception whereas throw clause is used to explicitly throw an exception.
  • throws clause is specified in the method signature whereas throw clause is used within a method.
  • Throws clause is often followed by a class whilst throw clause is often followed by an instance.
  1. How will you find if two strings are same or not?

Two strings in Java can be compared using the equals () method and not ==. Using == to compare strings will compare if the two string variables point to the same instance of a string object and not the actual value of the strings.

  1. How will you create the object of an abstract class?

Objects cannot be created for an abstract class.

Learn Hadoop to become a Certified Hadoop Developer through in 30 Days!

  1. I want to place the compiled java class files in a directory named DeZyre. How will you do that?

Use java – d .java. This command will place the compiled class files in a directory known as Java.

  1. What do you understand by mutable and immutable objects?

If the value of the object can be changed then it is referred to as a Mutable object. If after the creation of an objects, it value cannot be changed then it is an immutable object. String, Integer, Float in java are examples of immutable object whereas StringBuffer object is an example of mutable object in java.

  1. What is the difference between method overloading and overriding in Java?

Method overloading happens during compile time within a class whereas Method Overriding happens between two classes that have IS-A i.e. inheritance relationship. For method overriding we require parent and child classes whereas for method overloading a single class is enough.

  • Static binding is used for method overloading as the call to the overloaded method is made during the compile time whereas dynamic binding is used for method overriding as the call to the overridden method is made at run time.
  • Method overloading requires different argument list to the method whereas in method overriding the argument list has to be same.
  • Method overloading gives better performance over method overriding since the binding of the overloaded methods is done at compile time and not run time.
  1. What happens if you do not provide any package declaration in your java programming code?

When no package declaration is specified, java.lang package gets imported by default.

  1. What is the fundamental difference between shallow copy and deep copy in Java?

In Shallow copy a new object is created that has the same values like the original object. If any of the fields in the object reference other objects in that case only the memory address is copied.

In deep copy all fields are copied and copies are created for dynamically allocated memory that points to by the fields. In deep copy, an object is copied along with the other objects it refers to.

The default version of the clone () method will create a shallow copy of the object.

  1. Explain about garbage collection in Java.

Java manages memory automatically by removing the unused variable or objects from the memory. This process is referred to as garbage collection. User java programs cannot free the object memory , so the garbage collector (gc) in java free’s the objects or variables that are no longer being used by a program. JVM considers an object or variable as alive as long as it is being referenced by a program. Once it finds that the object cannot be reached by the program code, it is removed and so that the unused memory can be reclaimed.

  1. Where should the package statement appear within a java source code file?

The package statement should always be the very first line of a java program code.

  1. How will you implement multiple inheritance in Java?

Java does directly support multiple inheritance unlike C++ but multiple inheritance can be implemented in Java through interfaces.

  1.  How do you achieve abstraction in Java?

Abstraction means revealing only the required implementation details and hiding the internal details. Interfaces and abstract classes in java help achieve abstraction in Java.

  1. Is there any root class for all classes declared in a Java program?

“Object” class is the root class of all classes in java. Any class written in a java program extends the object class present in the default java.lang package.

  1. How can you create a deep copy of the complete java object along with its state?

A deep copy of the entire java object can be created by having the class implement the cloneable interface and make a call to its clone () method.

  1.  What are the access specifiers available in Java?

Java has 4 levels of access specifiers-

  1. Private -Variables, methods classes and constructors are visible only to the class.
  2. Protected – Variables, methods classes and constructors are visible to the package and also within all the subclasses.
  3. Public - Variables, methods classes and constructors are visible anywhere.
  4. Default- Visible to the package and there is no specific keyword to specify this access specifier, it is declared by default.
  1. What do you understand by Transient variables in Java?

Java has a special keyword known as transient which indicates that a variable should not be serialized when it is stored to streams of bytes. Whenever an object is transferred through a network it should be serialized to convert the object state into serial bytes.

Transient variables are initialized by their default value during de-serialization. For instance, for object transient variable, the value would be NULL.

  1.  Is it mandatory to have a catch block after every try block in the program code?

It is not necessary to have a catch block after every try block in the program code. All exceptions that are likely to be thrown should be mentioned in the throws clause of the method followed by either a catch block or a finally block.

  1. Under what circumstances is the finally block not executed?

If the program terminates due to a fatal error or it exits by calling the system.exit () method then finally block is not executed.

  1. What is synchronization in Java?

The process of monitoring the access to shared resources by multiple threads so that only one thread can access one resource at time is known as synchronization. Synchronization is used to avoid data consistency and corruption problems and also to prevent any kind of thread interference.

Java provides a special keyword known as “synchronized” which can be used either for synchronizing a block of code or for synchronizing a method.

  1. The keyword “synchronized” can be used a part of the method declaration.
  2. Or a block of code can be placed in synchronized keyword using ‘this’ java operator.
  1. Write an indefinite loop in Java.

for (;;) { }

Or

while (true)

{ }

  1. What are the different ways of creating a string object in Java?

String objects in java can be created either by using the new keyword or by using a string literal.

String Creation using a Literal –

String str= “DeZyre”;

String Object Creation using the “new” operator -

String str=new String ("DeZyre"); //creates two objects and one reference variable  

  1. Differentiate between a process and a thread.

In simple terms, threads are a part of a process i.e. a single process in java can spawn multiple threads.  Threads and processes in Java are independent paths of execution .A process gets its own memory address space whereas a thread shares the heap space belonging to the parent process. Every process in java has a unique process identifier, executable code and memory space whereas a thread has its own stack in Java but makes use of the process memory and shares it with other threads.

  1. How many objects will be created on executing the following code for creation of a string using the string literal?

String str1=”DeZyre”;

String str2=”DeZyre”;

String str3=”DeZyre”;

Only one object will be created because every time when we create a string literal, the JVM checks for the presence of the string in the string constant pool. Only if the string is not present in the pool then a new string instance will be created, otherwise a reference to the pooled instance is returned.

  1. Can you use an anonymous class to implement an interface and extend another class?

Yes, it is possible for an anonymous class to implement an interface and extend a super class but it cannot be used to do both at the same time in the same declaration.

  1. We know that the garbage collector in Java cleans up memory but still it does not guarantee that program will run out of memory. Can you explain the reason for this?

Java programs might use up the memory resources at a much faster pace than they are actually garbage collected and also the program might create objects which cannot be garbage collected.

  1. How will you declare a pointer in Java?

Java does not support pointers due to reliability and memory leak issues.

  1. Can you define a class inside an interface?

Yes but by default the class is static.

  1.  FileNotFoundException is inherited from the base class IOExcpetion. When trying to catch blocks for these exceptions, is it necessary to follow a particular order for the catch block statements?

Yes it is important to follow a particular order for the catch block statement for the two exceptions. The subclasses exception i.e. FileNotFoundException has to be caught first.

  1. What will be the initial value of an object reference that is declared as an instance variables?

All object reference variables in Java are assigned a NULL value.

  1. In a java program, we usually follow the main method declaration as public static void main (). What will happen if I alter the order of public and static declaration for the main () method in a java program?

Changing the order of the keywords ‘public’ and ‘static’ in the main () method declaration of a Java program does not matter but one must always ensure that the return type of the main () method i.e. void should always appear before main ().

  1. What is the base class for Exception and Error in Java?

Throwable

  1. Can you declare multiple classes in your Java source code file?

A single java program can have any number of class declarations but only one class can be declared as Public.

  1. I have 10 .java files in a folder. What is the process to compile all the files using a single command line execution instead of compiling each .java file separately?

Executing the “javac *.java “command from the directory location will compile all the files present in the folder with .java extension.

  1. Write a java line of code to declare a class as protected.

Only methods can be declared as protected in Java and not classes.

  1. What is the basic difference between a queue and a stack data structure?

Queue follows the first in first out (FIFO) rule whereas stack follows the last in first out rule (LIFO)

  1. What is the advantage of using a string literal in Java?

Using a string literal to create strings makes java memory more efficient as no new objects are created if they already exist in the string constant pool.

  1. Is it necessary to declare a main () method inside all java classes?

It is not necessary to declare a main () method inside all java classes unless the source class is a java application.

  1. Can you name any final classes defined in the Java API?

Java.lang.math and java.lang.string are some examples of final classes in Java API.


Would you like you get more information on java hadoop careers?

PREVIOUS

Online Hadoop Training


Answers
Currently have 3answers
Q: Would you like you get more information on java hadoop careers?
srinivas yes
Jan 10 2018, 12:53 PM
sd tesdsw@sds.com
Jul 29 2016, 02:43 PM
Sam Yes
Jul 28 2016, 12:43 PM

comments powered by Disqus