What are the common Java interview questions asked for 6 years of experience in Pune?
This article contains more than the required java interview questions that include all important topics such as Java core fundamentals, java collection frameworks, Java multithreading and concurrency, Java IO, JDBC, internal JVM, coding problems, object-oriented programming, etc.
Questions are also taken from various interviews and they, not at all, very difficult. You might have seen them on the phone or face-to-face interview.
The questions are also very useful for reviewing important topics such as multithreading and collection. So what are we waiting for? The following is a list of several java questions that are most often submitted in interviews for beginner and experienced Java developers.
So, without wasting anymore about your time, here is a list of several java core interview questions that are often submitted for beginner programmers. This list focuses on beginners and less experienced devs, like someone with 2 to 3 years experience in Java.
1. How does Java achieve platform independence?
Hint: Bytecode and Java Virtual Machine
2. What is the classloader in Java?
Hint: Part of the JVM that contains bytecodes for class. You can write yourself.
3. Write a java interview questions for experienced program to check what numbers are even or weird?
Hint: You can use Bitwise operators, such as Bitwise and, remember, even the number has zero at the end of the binary format and odd number have 1 in the end.
4. Difference between Arraylist and Hashset in Java?
Hint: All differences between lists and sets are valid here, eg. Order, duplicate, random search, etc. See fundamental java: Collection by Richard Warburton to learn more about Arraylist, Hashset and other important collections in Java.
5. What is checked by double locking in Singleton?
Hint: Check twice whether the instance is initialized or not, first without locking and second with locking.
6. How do you make Singleton safe thread in Java?
Hint: Many ways, such as using Enum or by using multiple locking patterns or using a nested static class.
7. When to use volatile variables in Java?
Hint: When you need to instruct JVM that variables can be modified by many utas and guidance to JVM that do not cache the value.
8. When to use a temporary variable in Java?
Hint: When you want to create non-serializable variables in class, which implements a serializable interface. In other words, you can use it for variables whose value doesn't want to save. See the complete MasterClass Java to learn about transient variables in Java.
9. Difference between transient and volatile variables in Java?
Hint: Really different, which is used in the context of serialization while others are used in concurrency.
10. The difference between serializable and external in Java?
Hint: can be externalized gives you more control over the serialization process.
11. Can we befall personal methods in Java?
Hint: No, because it is not visible in the subclass, the main requirements to override the method in Java.
12. The difference between hashtable and hashmap in Java?
Hint: Some but the most important is the hashtable, which is synchronized, while the hashmap does not. It is also a legacy and is slow compared to the hashmap.
13. Differences between Listand arranged in Java?
Hint: list booked and allow duplicate. The set is not ordered and does not allow duplicate elements.
14. Difference between Arraylist and vectors in Java
Hint: Many, but the most important thing is that Arraylist is not synchronized and fast when the vector is synchronized and slow. It's also a legacy class like hashtable.
15. The difference between hashtable and concurrenthashmap in Java?
Hint: More scalable. See fundamentals java: Collection by Richard Warburton to learn more.
16. How does concurenthashmap achieve scalability?
Hint: by dividing the map into a segment and only locks during the writing operation.
17. Which two methods will you overwrite for objects to be used as the key in the hashmap?
Hint: same and hashcode
18. The difference between waiting and sleeping in Java?
Hint: Waiting method () remove the key or monitor, while sleeping no.
19. The difference between telling and telling everything in Java?
Hint: Tell the notification of one random utas is waiting for the key while notifyall informing all the monitor waiting. If you believe only one utas waiting then use notify, or notifyall better. See Threading Essentials Mini-Course by JAVA Champion Heinz Kabutz to learn more about the Threading Basics.
20. Why did you overwrite the hashcode, along with the same () in Java?
Hint: To fulfill the equivalent contract and hashcode, which is needed if you plan to save your object into the collection class, eg. Hashmap or arraylist.
21. What exactly hashmap load factors?
Hint: The threshold that triggers the re-size hashmap generally 0.75, which means the hashmap resizes itself if 75 percent is full.
22. The difference between arraylists and linked lists in Java?
Hint: Just like an array and a link that is linked, one allows random searches while others don't. Insertion and easy removal on the list that is linked but easily searches on arrays. See the basics of Java: Collections, Richard Warburton courses about Pluralsight, to learn more about important collection data structures in Java.
23. The difference between countdownlatch and cyclicbier in Java?
Hint: You can reuse the CyclicBarrier after the barrier is broken but you cannot reuse the countdown after the count reaches zero.
24. When did you use UTAS vs runnable in Java?
Hint: Always
25. What is the meaning of safe enum in Java?
Hint: This means you cannot set an instance of different types of enum to the enum variable. For example if you have a variable like dayofweek days then you can't set that value from dayofmonth enum.
26. How does the Autoboxing of Integer work in Java?
Hint: by using the valueof () method in Java.