CoolInterview.com - World's Largest Collection of Interview Questions
Send Free SMS
 Interview Questions  
 Our Services  


INTERVIEW QUESTIONS J2EE JAVA DETAILS
Question :
What is the difference between a Vector and an Array. Discuss the advantages and disadvantages of both?
Category Java Interview Questions
Rating (3.3) By 8 users
Added on 10/13/2004
Views 2562
Rate it!
Answers:

The vector container class generalizes the concept of an ordinary C array. Like an array, a vector is an indexed data structure, with index values that range from 0 to one
less than the number of elements contained in the structure. Also like an array, values are most commonly assigned to and extracted from the vector using the subscript
operator. However, the vector differs from an array in the following important respects: The size of the vector can change dynamically. New elements can be inserted on to
the end of a vector, or into the middle. It is important to note, however, that while these abilities are provided, insertion into the middle of a vector is not as efficient as
insertion into the middle of a list. A vector has more "self-knowledge" than an ordinary array. In particular, a vector can be queried about its size, about the number of
elements it can potentially hold (which may be different from its current size), and so on.
A vector can only hold references to objects and not primitive types. Vector implementaions are usually slower then array because of all the functionality that comes with them. As implemented in Java, vector is a thread-safe class and hence all methods are synchronous methods, which makes them considerably slow.



If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       
    Related Questions
    View Answer
    How many different types of JDBC drivers are present? Discuss them.
    View Answer
    What does the keyword "synchronize" mean in java. When do you use it? What are the disadvantages of synchronization?
    View Answer
    What are native methods? How do you use them?
    View Answer
    What is RMI?
    View Answer
    What is JDBC? Describe the steps needed to execute a SQL query using JDBC.
    View Answer
    Access specifiers: "public", "protected", "private", nothing?
    View Answer
    What does the "final" keyword mean in front of a variable? A method? A class?
    View Answer
    Does Java have "goto"?
    View Answer
    Why "bytecode"? Can you reverse-engineer the code from bytecode?
    View Answer
    What synchronization constructs does Java provide? How do they work?
    View Answer

    Please Note: We keep on updating better answers to this site. Subscribe to our newsletter to get notified when better answer is posted.

    Notify me when better answer is posted!
    Email:

    View ALL Java Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2010 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions
    Page URL: http://www.coolinterview.com/interview/448/default.asp?cachecommand=bypass


    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Free SMS | Dedicated Servers | Joke of the Day

    2.42
    Cache = 0.015999 Seconds