Saturday, May 10, 2008

Java Interview Questions 51

251. Which containers use a Border layout as their default layout?- Window,
Frame and Dialog classes use a BorderLayout as their layout.

252. Which containers use a Flow layout as their default layout?- Panel and
Applet classes use the FlowLayout as their default layout.

253. What are wrapper classes?
Ans. Wrapper classes are classes that allow primitive types to be accessed as
objects.

254. What are Vector, Hashtable, LinkedList and Enumeration?- Vector : The
Vector class provides the capability to implement a growable array of objects.
Hashtable : The Hashtable class implements a Hashtable data structure. A Hashtable
indexes and stores objects in a dictionary using hash codes as the object’s keys.
Hash codes are integer values that identify objects. LinkedList: Removing or
inserting elements in the middle of an array can be done using LinkedList. A
LinkedList stores each object in a separate link whereas an array stores object
references in consecutive locations. Enumeration: An object that implements the
Enumeration interface generates a series of elements, one at a time. It has two
methods, namely hasMoreElements() and nextElement(). HasMoreElemnts() tests if this
enumeration has more elements and nextElement method returns successive elements of
the series.

255. What is the difference between set and list?- Set stores elements in an
unordered way but does not contain duplicate elements, whereas list stores elements
in an ordered way but may contain duplicate elements.

No comments:

Useful Information