CoolInterview.com - World's Largest Collection of Interview Questions
Start Your Own website Now
Sponsored Links

Interview Questions
Our Services

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!



    Send your Resume to 6000 Companies


  • INTERVIEW QUESTIONS C++ ARRAYS, STRINGS, POINTERS AND REFERENCES IN C++ DETAILS
    Question :
    Difference between "vector" and "array"?


    Category Arrays, Strings, Pointers and References in C++ Interview Questions
    Rating (0.4) By 928 users
    Added on 7/19/2006
    Views 4074
    Rate it!
    Answers:

    Vector and ArrayList are very similar. Both of them represent a 'growable array', where you access to the elements in it through an index.<br>ArrayList it's part of the Java Collection Framework, and has been added with version 1.2, while Vector it's an object that is present since the first version of the JDK. Vector, anyway, has been retrofitted to implement the List interface.<br>The main difference is that Vector it's a synchronized object, while ArrayList it's not.<br>While the iterator that are returned by both classes are fail-fast (they cleanly thrown a ConcurrentModificationException when the orignal object has been modified), the Enumeration returned by Vector are not.<br><br>Unless you have strong reason to use a Vector, the suggestion is to use the ArrayList<br><br> <br>



    Vector is also an array but the size of a vector can change
    dynamically. The size of an array is fixed.



    Posted by: Costi    

    Contact Costi Contact Costi

    Vector acts like an array. The vector
    is defined in header file <vector>. A
    vector container class is allow to access its element quickly. A vector is able to enlarge itself.
    Declaration syntax of array:
    data_type arrname[size]={};
    Declaration syntax of vector:
    vector<data_type> vectname;



    Posted by: Pradipta kumar Dash    

    Contact Pradipta kumar Dash Contact Pradipta kumar Dash

    Although they both can be visited the inside data by index number, vector is a kind of class(template). so, vector has a large mount of member functions to access his own data. Array is only a kind of data structure in memory and has no such member functions.



    Posted by: Tony Guo    

    Contact Tony Guo Contact Tony Guo

    Vector is same like a array,But vector size change dynamically as per requirement whereas array can not.Array size is fixed.



    Posted by: Archana Thange    

    Contact Archana Thange Contact Archana Thange

    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
    Explain "passing by value", "passing by pointer" and "passing by reference"

    View Answer
    What is "strstream??

    View Answer
    why array index starts from 0[zero] only?

    View Answer
    Why Pointers are not used in C Language. What are the main differences between C and C++

    View Answer
    How can double dimensional arrays be dynamically initialized in C++?




    View Answer
    Why always array starts with index 0?

    View Answer
    Can you allocate the memory using malloc() in C and deallocate the same memory using free() in c++

    View Answer
    What is a memory leak? How can we avoid it?
    View Answer
    Can you store multiple data types in System.Array?
    View Answer
    What is the difference between the System.Array.CopyTo() and System.Array.Clone()?
    View Answer


    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL Arrays, Strings, Pointers and References in C++ Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2014 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes


    Cache = 0.015625 Seconds