Home » JAVA Programming » Collections » Question
  1. What is the output of this program?
    import java.util.*;
    public class vector_Example
    {
    public static void main(String args[])
    {
    Vector object = new Vector(6,3);
    object.addElement(new Integer(10));
    object.addElement(new Integer(20));
    object.addElement(new Integer(50));
    object.removeAll(object);
    System.out.println(object.isEmpty());
    }
    }
    1. True
    2. False
    3. 0
    4. 1
    5. None of these
Correct Option: A

firstly elements 10, 20, 50 are entered in the vector object, but when object.removeAll(object); is executed all the elements are deleted and vector is empty, hence object.isEmpty() returns true.



Your comments will be displayed only after manual approval.