Coding

Published on July 14th, 2017 | by Guest

0

Top 10 Interview Questions & Answers for Java Developers

An organization hiring a Java developer is looking for someone who can code the applications flawlessly. For the period after Java training, the following is a very important list of ten Java interview questions. Make sure you tap the benefits of this comprehensive list of questions shared by our Java counterparts to crack your next interview.

1. What is immutable object? Can you write immutable object?

Basically Immutable classes are Java classes whose objects can not be altered once created. Any alteration in Immutable object result in new object. For example: String is immutable in Java. Mostly Immutable are also final in Java, to prevent sub class from overriding methods which can compromise Immutability. You can achieve same functionality by making member as non final but private, and without changing them except in constructor.

 

2. What is the difference when String is gets created using literal or new() operator?

 

When we create string with new() its created in heap and not included into string pool while String created using literal are created in String pool itself, which exists in Perm area of heap.

 

3. Define JAXB & JAXP?

 

JAXB: – It Stands for Java API for XML Binding. This standard characterizes a system for a script out Java objects as XML and for creating Java objects from XML structures.

JAXP: – Stands for Java API for XML Processing. This gives a typical interface for creating and using DOM, SAX, and XSLT APIs in Java regardless of which vendor’s implementation is actually being used.

 

4. Which two method you need to implement for key Object in HashMap?

 

To use any object as Key in HashMap, it must implement equals and hashcode method in Java. Learn how HashMap works in Java for detailed clarification on how equals and hashcode method is used to put and get object from HashMap.

 

5. Do you think all property of Immutable Object needs to be final?

 

Not compulsory as we can easily achieve the same by making member as non-final but private and not changing them except in the constructor. Additionally, avoid providing setter methods for them. In case of mutable object, then prevent leaking any reference for that member.

 

6. Can you quickly brief about Map, HashMap, HashTable, and TreeMap?

 

Map :- Map is an interface,

HashMap :- It is a class that implements a Map. It is unsynchronized and supports null values and keys.

Hashtable :- Hashtable is a synchronized version of HashMap

TreeMap :- It is similar to HashMap but uses Tree to implement Map

 

7. What is the difference between Executor.submit() and Executer.execute() method?

 

There is a difference when looking at exception handling. If your tasks throws up an exception and if it was applied with execute, this exception will go to the uncaught exception handler (when you don’t have provided one explicitly, the default one will just print the stack trace to System.err). In case you submitted the task with submit any thrown exception, checked exception or not, is then part of the task’s return status. For a task that was submitted with submit and that ends or terminates with an exception, the Future. Get will re-throw this exception, wrapped in an ExecutionException.

 

8. Does overriding hashcode() method have any performance implication?

 

A poor hashcode function will result in frequent collision in HashMap which eventually increase time for adding an object into Hash Map.

 

9. Can you differentiate an Interface and an Abstract class?

 

An abstract class may have instance methods, which can implement a default behavior. On the other hand, an interface can’t implement any default behavior. It can declare different instance and constants methods. While an interface has all the public members, an abstract class contains only class members like private, protected and so on.

 

10. What is the difference between HashSet and TreeSet?

 

The HashSet is executed using a hash table and along these, its elements are not ordered. The add, contains, and remove methods of a HashSet have constant time complexity O(1). Then again, a TreeSet is executed using a tree structure. The elements in a TreeSet are sorted, and along these, the add, contains, and remove methods have time complexity of O(logn).

Knowing answers to the above questions will certainly help you crack the Java developer certification first and then the subsequent job. You can learn any kind of Java course at Koenig Solutions.

Java certification courses must be learnt only from a reputed institute like Koenig Solutions. Here you can be assured of certified trainers to guide you on every aspect of this language. The Java certification is instrumental for a successful career in any IT field. Checkout Java Trends for the year 2017

So what are you waiting for? Choose your Java certification course today.

Tags: , , , , ,


About the Author

Contribution of guest authors towards Techno FAQ blog



Leave a Reply

Your email address will not be published. Required fields are marked *

Back to Top ↑