Collection Framework Interview Questions

Advertisements

Prev Tutorial Next Tutorial

Collection Framework Interview Questions for Freshers

Collection Framework Interview Questions

Main advantage of Collection Framework ?

Collections are grow-able in nature and hence based on our requirement we can increase or decrease the size and it store homogeneous data type. The basic aim of collection framework is to improve the performance of java based application.

Difference between Array and Collection

ArrayCollection
1Arrays are fixed in size and hence once we created an array we are not allowed to increase or decrease the size based on our requirement.Collections are grow-able in nature and hence based on our requirement we can increase or decrease the size.
2Arrays can hold both primitives as well as objects.Collections can hold only objects but not primitive.
3Performance point of view arrays faster than collectionPerformance point of view collections are slower than array
4Arrays can hold only homogeneous elements.Collections can hold both homogeneous and heterogeneous elements.
5Memory point of view arrays are not recommended to use.Memory point of view collections are recommended to use.
6For any requirement, there is no ready method available.For every requirement ready made method support is available.

Note: Above difference is same for difference between Array and any Collection object (like Vector, ArrayList, LinkedList).

Difference between Iterator and ListIterator

IteratorListIterator
1Iterator is one of the super Interface for ListIteratorListIterator is one of sub-Interface of Iterator
2This Interface is allow to retrieve the element only in forward directionThis Interface is allow to retrieve the element in both direction either in forward and backward direction.

How many Technique to retrieve elements from Collection object ?

Java support following technique to retrieve the elements from any collection object.

  • foreach loop
  • Iterator interface
  • ListIterator interface
  • Enumeration interface

Difference Between Vector and ArrayList ?

VectorArrayList
1Vector is legacy Collection Framework (old class).ArrayList is new Collection Framework.
2Vector is Synchronized by default.ArrayList is not Synchronized.
3For retrieving elements from Vector class can be use foreach loop, Iterator, ListIterator and Enumaration.For retrieving elements from ArrayList class can be use foreach loop, Iterator and ListIterator.

Difference between HashMap and HashTable ?

HashMapHashTable
1HashMap is a new class in java API.HashTable is a legacy class in java API.
2HashMap is not Synchronized.HashTable is Synchronized.
3HashMap allows maximum one null key and multiple null value.HashTable does not allows any null key and null values.

Difference between HashMap and TreeMap

HashMapTreeMap
1HashMap class object organizes the data in the form of key, value pair by following hasing mechanism.TreeMap class object organized the data in the form of key, value pair by following binary tree concept.
2HashMap store data in undermined form.TreeMap store data in sorted order.
3In HashMap the operation like insertion, deletion and modification takes less time.In TreeMap the operation like insertion, deletion and modification takes more time.
3Elements retrieving time of HashMap is more.Elements retrieving time of TreeMap is less.

Difference between HashSet and TreeSet

HashSetTreeSet
1HashSet class object organizes the data in the form HashTable by following Hashing mechanism.TreeSet class object organized the data by following binary tree concept.
2HashSet display data in undermined form.TreeSet display data in sorted order.
3In HashSet the operation like insertion, deletion and modification takes more time.In TreeSet the operation like insertion, deletion and modification takes less time.
3Elements retrieving time of HashSet is more.Elements retrieving time of TreeSet is less.

What is Properties Files ?

A property file is one type of the file which organizing the date in the form of (key, value) pair. A property file is a text file which is to be created in any editors like-notepad, Editpuls and etc. Property file should be saved on same file name with on extension .prop or .rbf.

Why Legacy Collection Framework are not use for web based applications. ?

Legacy Collection Framework are Synchronized because of this we can not use Legacy Collection Framework for web based applications.


Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements