Top 49 Java Hadoop Developer Interview Questions
Q1. What Are The Different Ways Of Creating A String Object In Java?
String objects in java may be created either via the usage of the brand new keyword or via the use of a string literal.
String Creation the use of a Literal –
String str= “DeZyre”;
String Object Creation the use of the “new” operator -
String str=new String ("DeZyre"); //creates two gadgets and one reference variable
Q2. Where Should The Package Statement Appear Within A Java Source Code File?
The package assertion need to usually be the first actual line of a java software code.
Q3. 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 summary class it's far feasible to use the non-static methods.
Q4. 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.
Q5. Differentiate Between Throw And Throws In Exception Handling.
Throw clause is used when a person wants to throw a customized specific exception. Throw clause is used if there may be a need for a selected exception to be thrown to the calling technique.
Try
if (age>=100) throw new AgeBarException (); //This is a custom designed exception
else
....
Catch (AgeBarException ex)
...Code to address Exception.....
Throws Clause lists all of the exceptions that piece of code would possibly throw. Throws clause provides a warning to the invoking approach that these are the list of exceptions it would throw and a lot of these need to be dealt with.
Throws is used to claim an exception while throw clause is used to explicitly throw an exception.
Throws clause is targeted within the method signature while throw clause is used inside a way.
Throws clause is regularly observed via a category at the same time as throw clause is often accompanied via an example.
Q6. What Is The Difference Between A Class Variable And An Instance Variable In Java?
Class Variables best have a unmarried copy of the variable and are declared with static modifiers. Every item of the class shares a unmarried reproduction of the magnificence variable, so if any modifications are made to a class variable they may be visible through all the gadgets of a category. A elegance variable is allocated memory while the elegance is loaded first time.
Example of a Class Variable Declaration in Java
Public elegance Product
public static int Barcode;
Instance variables belong to an object and are specific with out a static modifier. Every item of the class could have its own private reproduction of the instance variable in contrast to class variables wherein single copy of the variable is shared through different objects of the class.
Example of an Instance Variable Declaration in Java
public elegance Product
public int Barcode;
Big Data and Hadoop Certification Training
If you would like greater data approximately Big Data careers, please click on the orange "Request Info" button on pinnacle of this page.
Q7. Where Can A Protected Method Be Accessed?
Any blanketed technique may be accessed with the aid of all of the instructions of the equal package deal and also by the subclass of the class in some other package.
Q8. Write A Java Line Of Code To Declare A Class As Protected?
Only techniques may be declared as included in Java and no longer instructions.
Q9. Is It Necessary To Declare A Main () Method Inside All Java Classes?
It isn't essential to claim a first-rate () technique interior all java lessons unless the supply class is a java application.
Q10. What Is The Advantage Of Using A String Literal In Java?
Using a string literal to create strings makes java memory more green as no new gadgets are created in the event that they exist already inside the string constant pool.
Q11. How Will You Achieve Multi-threading In Java?
Multithreading in Java can be completed in two methods :-
By defining a new class which implements the runnable interface. An item of that class is then surpassed to constructor approach of Thread.
By defining a brand new elegance that extends the thread class.
Q12. 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 vicinity will assemble all of the documents gift inside the folder with .Java extension.
Q13. Can You Explain The Difference Between Path And Classpath?
These are the working gadget environment variables in which PATH variable defines the system in which executable files are present while CLASSPATH is used to specify the region of .Magnificence documents.
Q14. Can You Use An Anonymous Class To Implement An Interface And Extend Another Class?
Yes, it's miles possible for an nameless magnificence to put into effect an interface and expand a high-quality magnificence however it can not be used to do each on the identical time within the equal declaration.
Q15. How Can You Create A Deep Copy Of The Complete Java Object Along With Its State?
A deep reproduction of the entire java object may be created by way of having the elegance enforce the cloneable interface and make a call to its clone () approach.
Q16. How Will You Implement Multiple Inheritance In Java?
Java does at once guide a couple of inheritance not like C++ but multiple inheritance can be carried out in Java thru interfaces.
Q17. What Happens If You Do Not Provide Any Package Declaration In Your Java Programming Code?
When no package statement is particular, java.Lang package receives imported via default.
Q18. Filenotfoundexception Is Inherited From The Base Class Ioexception. When Trying To Catch Blocks For These Exceptions, Is It Necessary To Follow A Particular Order For The Catch Block Statements?
Yes it's miles vital to observe a selected order for the trap block announcement for the 2 exceptions. The subclasses exception i.E. FileNotFoundException needs to be stuck first.
Q19. Explain About Garbage Collection In Java?
Java manages memory automatically with the aid of putting off the unused variable or items from the reminiscence. This procedure is called rubbish collection. User java programs can not free the object reminiscence , so the garbage collector (gc) in java unfastened’s the items or variables which might be not being utilized by a software. JVM considers an item or variable as alive so long as it's far being referenced with the aid of a program. Once it reveals that the object cannot be reached via the program code, it is removed and so that the unused memory may be reclaimed.
Q20. Which Collection Interface In Java Is Used To Maintain Unique Elements?
Map interface in Java maps specific keys to values, given a key and price pair- the price is stored in the Map object which may be retrieved the usage of the key.
Q21. What Platform And Version Of Java Is Required To Work With Apache Hadoop?
The advocated java version to with Apache Hadoop is 1.6 or better, desired from Sun. Windows and Linux are the supported running structures to paintings with Hadoop however Mac OS is famous for running with hadoop.
Q22. 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 may be created due to the fact whenever while we create a string literal, the JVM tests for the presence of the string within the string steady pool. Only if the string is not present in the pool then a brand new string example will be created, in any other case a connection with the pooled instance is lower back.
Q23. I Want To Place The Compiled Java Class Files In A Directory Named Desire. How Will You Do That?
Use java – d .Java. This command will vicinity the compiled class documents in a listing known as Java.
Q24. How Do You Achieve Abstraction In Java?
Abstraction me revealing most effective the desired implementation information and hiding the inner details. Interfaces and abstract instructions in java help obtain abstraction in Java.
Q25. What Is The Difference Between An Abstract Class And Interface?
Interface isn't the same as an abstract elegance because interface is only a kind that may be satisfied by a class which implements the interface. Interfaces in java help put in force a couple of inheritance because a class can enlarge simplest a further class.
Interface do no longer have any implementation and simply are limited to constants and public methods while summary elegance in java can have partial implementation at the side of static strategies and guarded get entry to blocks. A class can expand simplest one summary magnificence but it may put into effect several interfaces.
Q26. What Is Synchronization In Java?
The technique of tracking the access to shared sources with the aid of more than one threads so that only one thread can get right of entry to one aid at time is referred to as synchronization. Synchronization is used to keep away from facts consistency and corruption problems and additionally to save you any type of thread interference.
Java offers a special keyword referred to as “synchronized” which can be used both for synchronizing a block of code or for synchronizing a method.
The key-word “synchronized” may be used part of the technique statement.
Or a block of code may be located in synchronized key-word the use of ‘this’ java operator.
Q27. 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
Changing the order of the keywords ‘public’ and ‘static’ in the principal () technique declaration of a Java software does not count but one should continually make certain that the return form of the primary () method i.E. Void have to constantly seem earlier than fundamental ().
Q28. Is Java The Only Language For Hadoop Jobs To Be Written?
It is not vital to jot down Hadoop jobs in Java language, there are numerous other methods to put in writing hadoop jobs using non-java codes. Hadoop Streaming permits hadoop map and reduce tasks to be written in the shape of any executable script.
Q29. 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 price.
Q30. Under What Circumstances Is The Finally Block Not Executed?
If the program terminates because of a deadly errors or it exits by using calling the system.Go out () approach then in the end block is not achieved.
Q31. Is There Any Root Class For All Classes Declared In A Java Program?
“Object” magnificence is the root magnificence of all training in java. Any magnificence written in a java application extends the item magnificence present inside the default java.Lang bundle.
Q32. How Will You Create The Object Of An Abstract Class?
Objects can not be created for an summary elegance.
Q33. Write An Indefinite Loop In Java?
For (;;)
Or
while (actual)
Q34. Can You Define A Class Inside An Interface?
Yes however through default the class is static.
Q35. What Are The Access Specifiers Available In Java?
Java has 4 ranges of get right of entry to specifiers:-
Private -Variables, strategies lessons and constructors are seen best to the elegance.
Protected – Variables, techniques lessons and constructors are visible to the bundle and additionally within all the subclasses.
Public - Variables, techniques training and constructors are visible everywhere.
Default- Visible to the package and there may be no specific keyword to specify this get entry to specifier, it is declared by default.
Q36. What Do You Understand By Trient Variables In Java?
Java has a unique key-word called trient which shows that a variable ought to no longer be serialized when it is saved to streams of bytes. Whenever an item is trferred through a network it have to be serialized to convert the item country into serial bytes.
Trient variables are initialized with the aid of their default value in the course of de-serialization. For instance, for item trient variable, the fee could be NULL.
Q37. Can You Declare Multiple Classes In Your Java Source Code File?
A single java application can have any number of sophistication declarations however simplest one class can be declared as Public.
Q38. Differentiate Between A Process And A Thread?
In simple phrases, threads are a part of a technique i.E. A single procedure in java can spawn a couple of threads. Threads and methods in Java are unbiased paths of execution .A system receives its personal memory deal with space whereas a thread stocks the heap area belonging to the figure method. Every system in java has a unique system identifier, executable code and memory space while a thread has its very own stack in Java but uses the system memory and shares it with different threads.
Q39. We Know That The Garbage Collector In Java Cle Up Memory But Still It Does Not Guarantee That Program Will Run Out Of Memory. Can You Explain The Reason For This?
Java programs would possibly expend the memory assets at a much faster tempo than they're really rubbish amassed and also this system may create items which can not be garbage accumulated.
Q40. 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 simplest variable that wishes to be set and should point to the java set up directory.
Q41. What Is The Base Class For Exception And Error In Java?
Throwable
Q42. Is It Mandatory To Have A Catch Block After Every Try Block In The Program Code?
It isn't always necessary to have a capture block after every strive block inside the software code. All exceptions which are probable to be thrown ought to be stated within the throws clause of the technique observed via both a catch block or a eventually block.
Q43. What Is The Difference Between Method Overloading And Overriding In Java?
Method overloading happens during bring together time inside a class while Method Overriding happens between two instructions that have IS-A i.E. Inheritance dating. For approach overriding we require discern and child training whereas for technique overloading a single elegance is enough.
Static binding is used for method overloading as the call to the overloaded technique is made during the bring together time whereas dynamic binding is used for approach overriding as the decision to the overridden method is made at run time.
Method overloading requires one-of-a-kind argument list to the technique while in approach overriding the argument list must be equal.
Method overloading offers better overall performance over technique overriding since the binding of the overloaded techniques is carried out at compile time and now not run time.
Q44. What Is The Return Type Of Main () Method In Java?
Main () approach in java does not go back something and subsequently is continually declared as void.
Q45. What Is The Fundamental Difference Between Shallow Copy And Deep Copy In Java?
In Shallow replica a brand new item is created that has the identical values like the original object. If any of the fields in the object reference other objects if so handiest the reminiscence cope with is copied.
In deep copy all fields are copied and copies are created for dynamically allotted memory that points to by the fields. In deep replica, an object is copied along side the alternative items it refers to.
The default model of the clone () approach will create a shallow replica of the item.
Q46. How Will You Declare A Pointer In Java?
Java does now not aid pointers because of reliability and reminiscence leak issues.
Q47. What Do You Understand By Mutable And Immutable Objects?
If the fee of the item can be modified then it is referred to as a Mutable item. If after the creation of an gadgets, it value can not be changed then it is an immutable object. String, Integer, Float in java are examples of immutable item whereas StringBuffer item is an instance of mutable item in java.
Q48. How Will You Find If Two Strings Are Same Or Not?
Two strings in Java may be in comparison the use of the equals () approach and not ==. Using == to examine strings will examine if the 2 string variables factor to the identical example of a string item and now not the actual fee of the strings.
Q49. What Is The Basic Difference Between A Queue And A Stack Data Structure?
Queue follows the primary in first out (FIFO) rule whereas stack follows the remaining in first out rule (LIFO)

