Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Download
Standard view
Full view
of .
Look up keyword
Like this
7Activity
0 of .
Results for:
No results containing your search query
P. 1
Collections Questions

Collections Questions

Ratings:

5.0

(1)
|Views: 398|Likes:
Published by api-3744705

More info:

Published by: api-3744705 on Oct 15, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

Collections

1). HashMap is an Interface. How we can create an instance to that HashMap?
Ans: HashMap is an class which implements the map interface. The H.M doesn\u2019t
guarented the order of its elements. Therefore the order in which they have added to a
H.M is not necessarly the order in which they are read by an iterator.

2)When we will use ArrayList and HashMap?
ArrayList: - 1. Suppose dynamic Arrays that can grow is needed---
--- ArrayList can dynamically increase and decrease the size.
---- When size is exceeded the collection is automatically enlarged. When objects are
removed the Array may be shrunk.
HashMap: - 1. H.M class implements the map interface.
1. The execution time of basic operations such as get() and put()

2. H.M doesn\u2019t guaranteed the order of its elements:
HashMap hm=new HashMap ();
Hm.put (\u201cLARA\u201d, newString (243546);

3. Based on name it will retrieve the value.
3) When we use HashMap and HashTable?
HashTable: - H.T is syn., based on requirement, if client don\u2019t need efficiently
then we use H.T (because syn. reduces the efficiency)
HashMap: - If client want efficiently then we will use H.M(\u2018cos its not syn.)
4) Difference between HashTable and HashMap?

HashTable
1. HashTable is syn
2. HashTable doesn\u2019t accept nulls, based on value retrieve key.

HashMap
4. HashMap is not syn.
5. HashMap accepts nulls based, on value retrieve key.

5). what is a set?
Set is an interface implements collection interface, to represent a set of unique
elements.
6). what is list?
List interface implements collection interface, to maintain a sequence of elements
which need not be unique.
Classes are: array list, vector, linked list.
7Q).What is the difference b/w HashTable and HashMap?
Ans:
HashTable
HashMap
1) Is Synchronous
is not Synchronous
2) It will not accept Null Values
Accept Null Values
3) Based on the key it retrieve Value
Based on the key it retrieve Value
8) Diff. b/w array and arraylist ()
Ans: Array: we have to declare some datatype. Only fixed n.of elements we can
store.
ArrayList: we can store any type of datatype. Dynamically increase (we can add
n.of elements)
9). Diff. b/w Vector and ArrayList
Ans: Vector: Synchronous process
ArrayList: Non Synchronous.
10).In application server what we will declare ArrayList (or) vector.why?
Ans: we will use array list in application server .because application server provide
syn process.
11) Which collection is fast??
Ans: ArrayList. Because is not asynchronous.
12). what is static factory???

Ans:: static factory methods from the collections class can b utilized to create decorators
that provide thread safety for collection.
Collection

Synchronized collection (collection c )
List
Synchronized List (List list)
Map
Synchronized Map (Map m)
Set
Synchronized Set (set s)
SortedMap
Synchronized SortedMap (SortedMap m)
SortedSet
Synchronized SortedSet (SortedSet s)
13) Java.util classes sub classes: - Array list, array, HashMap, Hashset, Hashtable(1.0) ,
linked list, properties(1.0), stacks(1.0),TreeMap, TreeSet, vector(1.0).
14) Java.util interfaces sub classes: - collection, compartor, iteration, list, map, set,
sorted set, sortedMap.
15). Diff b\w array &vector?
Ans: array: when we want to declare same data type and they are only a fixed no. of
elements we can store.
Vector we can store any type of data type and the size of vector can dynamically
increase (we can add no.of elements and it is a syn.)
16). we have arraylist if we want provide syn what we have to do?
Ans: ArrayList list = new ArrayList ();
Public static List synchronizedList (list);
17). what are the collections in java?
ans; set, list, sorted set, comparator, iterator , map, sorted map
Classes are: array list, vector, linked list.
18). What is a set?
Set is an interface extends collection interface, to represent a set of unique
elements.
20). What is list?
List interface extends collection interface, to maintain a sequence of elements
which need not be unique.
21) When we use HashMap and HashTable?
HashTable :- H.T is syn.based on requirement, if client don\u2019t need efficiently
then we use H.T(because syn. Decreased the efficiency)
HashMap :- If client want efficiently then we will use H.m(\u2018cos its not syn.)
22) When we will use ArrayList and HashMap?
ArrayList :- 1. Suppose dynamic Arrays that can grow is needed---
---ArrayList can dynamically increase and decrease the size.
---- When size is exceeded the collection is automatically enlarged. When objects are
removed the Array may be shrunk.
HashMap: - 1. H.M class implements the map interface.
2. The execution time of basic operations such as get() and put()

3. H.M doesn\u2019t guarented the order of its elements:
HashMap hm=new HashMap ();
Hm.put (\u201cLARA\u201d, newString (243546);

4. Based on name it will retrieve the value.
23). HashMap is an Interface. How we can create an instance to that HashMap ?

HashMap is a class which implements the map interface. The H.M doesn\u2019t
guarented the order of its elements. Therefore the order in which they have added to a
H.M is not necessarly the order in which they are read by an iterator.

24)What is Collection.
Ans: collection is
31) What is the difference between Hashmap and Hashtable. (*)
32)What is the difference between Vector, Array and Arraylist. (*
36) What is the difference between List, Set and Map. (*)

40)What is the difference between Iterator and Enumeration
41) What is the difference between Comparable and Comparator.
44) What is the difference between HashMap and TreeMap. (*)
56) What are the various Collection classes available. (*)

58)Which Collection class is used for FIFO in Java. 59) Which Collection class is used for LIFO in Java. 63) Can we add Hashtable/HashMap to a vector.

Activity (7)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
rajaramansuresh liked this
srivig liked this
Prahallad liked this
tosankar14 liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->