Java Collection Framework Question and Answers

5. What is difference between arraylist and vector?
 
  • Synchronization : ArrayList is not thread safe whereas Vector is thread safe. In Vector class each method like add(), get(int i) is surrounded with a synchronized block and thus making Vector class thread safe.
  • Data growth: Internally, both the ArrayList and Vector hold onto their contents using an Array. When an element is inserted into an ArrayList or a Vector, the object will need to expand its internal array if it runs out of room. A Vector defaults to doubling the size of its array, while the ArrayList increases its array size by 50 percent.
 
Your Name Your Email-ID
Your Answer
6. What is the advantage of generic collection?
  If we use generic class, we don't need typecasting. It is type safe and checked at compile time.
 
Your Name Your Email-ID
Your Answer
7. What is the Simple Time Zone class?
 
  • Simple Time Zone is a concrete subclass of Time Zone class.
  • The Time Zone class represents a time zone that is to be used with Gregorian calendar.
 
Your Name Your Email-ID
Your Answer
8. What is the resource bundle class?
 
  • A resource bundle class is a group of related sub classes which are sharing the same base name.
  • For example, Button Label is the base name.
  • All the characters following the base name indicates the following elements respectively.
 
Your Name Your Email-ID
Your Answer
1234 Page 2 of 4