Wednesday, August 13, 2008

Core Java Interview Questions - Differene Questions

1. Difference between Vector and ArrayList
2. Difference between Array and ArrayList




Answers
1. Vector and ArrayList?
  • All methods in vector are synchronized while in Arraylist they are not synchronized(not threadsafe)
  • When Vector reaches the end of its size, it doubles its size to accomdate new objects. whereas Arraylist grows by 50% of initial size.
2. Array and ArrayList?
  • Array is can store only a set similar objects and its size is fixed
  • ArrayList is internally an error, but can grow dynamically (so size is not fixed), its not synchronized.

No comments: