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 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 not overriding hashcode() method has 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. Could 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 course 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.

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

Views: 15

Comment

You need to be a member of Oracle Community to add comments!

Join Oracle Community

Oracle Community On

I'm not a fan of advertising, and so I will not be including any advertisements on OracleCommunity.net. However, managing this community does not come without cost! If you are willing to donate to help pay for the monthly community fees and domain services I accept Bitcoin and PayPal donations.

Donate Bitcoins

Badge

Loading…

Blog Posts

Augment the Speed and Efficiency of Website Development with Joomla

Over the past few years, Joomla has emerged out as one of the greatest platforms for designing, developing, and deploying websites and web applications worldwide. Joomla scales up extremely well, uses less memory and gives a brilliant performance. Hire skilled and experienced Joomla developers to use Joomla CMS for developing simple and complex corporate websites. You can even enhance the functioning of your existing website by using this open source platform.

By outsourcing Joomla…

Continue

Posted by Alvaro Dee on March 20, 2017 at 4:00am

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…

Continue

Posted by Michael Warne on March 17, 2017 at 3:00am

Get the Best Website for Your Business in a Set Time Frame

If you sell products online, you must be knowing how time-consuming and mundane it is to upload products. There are chances of you looking for someone to handle your product data entry tasks. A company that has a wealth of experience and is known for providing its customers with data entry services for a variety of eCommerce solutions can deal efficiently with high volumes of work without any hassle.…

Continue

Posted by Alvaro Dee on March 17, 2017 at 2:47am

Sell More with Better Quality Product Images

In this dynamic business environment, a company that thinks strategically stays ahead of the competition. Every business having an online presence requires pictures of high quality for advertising its products and services. Companies have today understood that people always relate better to visual cues. Compelling pictures have the ability of making…

Continue

Posted by Alvaro Dee on March 14, 2017 at 11:46pm

© 2017   Created by Steve Karam.   Powered by

Badges  |  Report an Issue  |  Terms of Service