Top java interview questions
We share some most frequently and important java interview questions.
Not only are these questions frequently asked by interviewers, but also
that they are essential for you to master core Java.
How do you implement your own Key Object for HashMap?
To answer such as question, you probably should also get familiar with the concept of HashTable. Since HashTable use a hash function to map an object to the index of the underlying Array, you need to implement the hashcode method. As there can be conflicts: Two object generate the same hashcode, we also need to implement the equal function to ultimately determine whether two objects are the same based on the business rules.
The difference between StringBuilder and StringBuffer in Java
The difference between HashMap and HashTable in Java
They are similar questions. Both StringBuffer and HashTable are synchronized, while both StringBuilder and HashMap are not synchronized. So, StringBuilder and HashMap are faster but they are not thread safe.
The difference between ArrayList and Vector
What is Singleton? How do you implement it?
The concept of Singleton is simple. It is the easiest design pattern. It means there is only one instance (object) or a class in the application.
There are many methods to implement a Singleton pattern. To answer this question correct, you must make it Thread safe and Fast.
What are difference between Abstract and Interface in Java?
A simple answer can be:
Both must be subclassed to create instance.
Abstract can contain non abstact method, but Interface contains only abstact method.
If a sub class extends an abstract class, it can not extends other abstract class anymore, but a sub class can implement many interfaces.
See two articles that have a detailed discussion:
Recommend Book to Learn Java: