For example, some Collection implementations like List allow duplicate elements whereas other implementations like Set don't. A lot of the Collection implementations have a public clone method. However, it doesn't make sense to include it in all implementations of Collection. This is because Collect...
This Java collection interview questions is I guess most popular one. Most of Java programmer who has at least 2 years of experience has seen this question on core Java or J2EE interview. Well there are many difference between them but most important isthread-safety,HashMapis not thread-safe ...
20 Java Collections Interview Questions In java, collection interview questions are mostly asked by the interviewers. Here is the list of mostly asked
If you are working on Enterprise applications, I am sure that JDBC API is a part of it. JDBC API provides database connectivity for relational databases, such as MySQL and Oracle. This article has a collection of 40+ interview questions related to the JDBC API. They cover areas from basic...
# Expert Level Collections Interview Questions 27. How to Create Read-only Collections? Use the following methods: Collections.unmodifiableList( list ); Collections.unmodifiableSet( set ); Collections.unmodifiableMap( map ); These methods take a collection parameter and return a new read-only collectio...
9) Which collection classes allow NULL? ArrayList, LinkedList, HashSet, HashMap (keys & values) and Hashtable (values only) all allow NULL. The two exceptions are TreeMap and TreeSet. 10) What happens if we add the same key with different values to a HashMap?
It is an ordered collection (by index) and not sorted. It implements the Random Access Interface. Example:public class Fruits{public static void main (String [ ] args){ArrayList <String>names=new ArrayList <String>();names.add (“apple”);names.add (“cherry”);names.add (“kiwi”);nam...
Top Java Interview Questions And Answers – Set 3 1) What is the default size of the load factor in the hashing-based collection? The default size is 0.75 and the default capacity is computed as Initial capacity * Load factor. 2) What is a package?
Packages in Java, are the collection of related classes and interfaces which are bundled together. By using packages, developers can easily modularize the code and optimize its reuse. Also, the code within the packages can be imported by other classes and reused. ...
Iterator is an interface which is used to step through the elements of a Collection. 6What is similarities/difference between an Abstract class and Interface? 6.1Similarities 6.1.1They can be used to implement the polymorphism. 6.1.2Both of them can not be instantiated. ...