ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
what is the difference between ArrayList and Vector
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: what is the difference between ArrayList and Vector
Answer
# 1
1. Arraylist is not synchronized while vector is.
2. Arraylist has no default size while vector has a default 
size of 10.
 
Is This Answer Correct ?    24 Yes 9 No
Mohammed Salim
 
  Re: what is the difference between ArrayList and Vector
Answer
# 2
Arraylist is not synchronized where as Vector is
synchronized.   
No default size for Arraylist where as Vector is having a
default size of 10.
 
Is This Answer Correct ?    21 Yes 8 No
Harmeet
 
 
 
  Re: what is the difference between ArrayList and Vector
Answer
# 3
i would like to add a new point to above answers.
we can specify the increment size with the vector and with 
array list we cannot
 
Is This Answer Correct ?    15 Yes 2 No
Narasimha
 
  Re: what is the difference between ArrayList and Vector
Answer
# 4
ArrayList is non synchronized.Vector is
synchronized.ArrayList is very fast because non
synchronized.we can specify the increment size with the
vector and with arrayList we cannot
 
Is This Answer Correct ?    12 Yes 0 No
Dara
 
  Re: what is the difference between ArrayList and Vector
Answer
# 5
Hi...
ArrayList is not synchronized(not Thread-safe)but Vector is 
Synchronized(Thread-safe)
ArrayList gives u better performance than Vector
 
Is This Answer Correct ?    9 Yes 1 No
Devarathnam
 
  Re: what is the difference between ArrayList and Vector
Answer
# 6
I am adding some more points to the above answers.

Array list and Vector have one in common. They both 
implement Random Access.
It is possible to provide synchronization using Array List 
by using the utility methods in Collection.
 
Is This Answer Correct ?    2 Yes 3 No
Ganesh Nagalingam
 
  Re: what is the difference between ArrayList and Vector
Answer
# 7
for addition of 3rd answer incresing capacity in vector 
using with ensureCapacity(int x) method
 
Is This Answer Correct ?    5 Yes 0 No
Surya
 
  Re: what is the difference between ArrayList and Vector
Answer
# 8
ArrayList and vector both are dynamically growing arrays.
ArrayList is not thread safe where as vector is thread safe.
vector is legacy class and ArrayList is newly added.
by default ArrayList capacity is 0 where as Vector intial 
capacity is 10.
vector is growing by its size doubled.
ArrayList is increse by its size half(50%)
 
Is This Answer Correct ?    15 Yes 2 No
M.sridhar
 
  Re: what is the difference between ArrayList and Vector
Answer
# 9
ArrayList is having only those method defined within its
collection class but in case of vector it is having its own
method which is not a part of its collection class.
 
Is This Answer Correct ?    8 Yes 2 No
Bhushan Singh
 
  Re: what is the difference between ArrayList and Vector
Answer
# 10
import java.util.*;
public class VectorDemo{
  public static void main(String[] args){
    Vector<Object> vector = new Vector<Object>();
    int primitiveType = 10;
    Integer wrapperType = new Integer(20);
    String str = "tapan joshi";
    vector.add(primitiveType);
    vector.add(wrapperType);
    vector.add(str);
    vector.add(2, new Integer(30));
    System.out.println("the elements of vector: " + vector);
    System.out.println("The size of vector are: " + 
vector.size());
    System.out.println("The elements at position 2 is: " + 
vector.elementAt(2));
    System.out.println("The first element of vector is: " + 
vector.firstElement());
    System.out.println("The last element of vector is: " + 
vector.lastElement());
    vector.removeElementAt(2);
    Enumeration e=vector.elements();
    System.out.println("The elements of vector: " + vector);
    while(e.hasMoreElements()){
      System.out.println("The elements are: " + 
e.nextElement());
    }  
  }
}
 
Is This Answer Correct ?    3 Yes 2 No
Tamilvendan
 
  Re: what is the difference between ArrayList and Vector
Answer
# 11
Arraylist also has the initial capacity as 10.
Please check the following code in ArrayList class:

public ArrayList() {
	this(10);
    }
 
Is This Answer Correct ?    0 Yes 0 No
Thoi
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
What is the Set interface?  2
How to set the Heap size in Java ? HCL2
When we will use an Interface and Abstract class?  3
what is main purpose of abstract class?  2
printstream class method println() is calling using System class and its static object out .how it is explain any one in detail with example ? TCS1
What is the difference between overloading and overriding a function? Infosys7
write java code to print second max number in the array Huawei9
what is Thread?  6
adapter class ?  2
what is webservices Mind-Tree4
What is the difference between jsp and servlet? Symphony5
can we write a program with out a class in core java? Wipro5
Name the methods in mouse listeners ?  3
How to transfer data from an Applet to Servlet ?  1
Explain Connection Pooling?  3
What is the immediate superclass of Menu?  1
Interface A { String test(); } Interface B { int test(); } Create a class AB which must implements both A & B interfaces. Hewitt13
What happens when a main method is declared as private? Sun-Microsystems8
Difference between String & StringBuffer Wipro6
What are the OOPS concepts in Java ? Satyam3
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com