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(5));
    object.addElement(new Integer(7));
    object.addElement(new Integer(9));
    System.out.println(object.elementAt(2));
    }
    }
    1. 6, 3
    2. 5
    3. 7
    4. 9
    5. None of these
Correct Option: D

object.elementAt(2) returns the value stored at index 2, which is 9.



Your comments will be displayed only after manual approval.