Collections


  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. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

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


  1. Which of these methods is used to add elements in vector at specific location?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    addElement() is used to add data in the vector, to obtain the data we use elementAt() and to first and last element we use firstElement() and lastElement() respectively.



  1. What is the name of a data member of class Vector which is used to store a number of elements in the vector?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    elementCount


  1. Which of these is the interface of legacy?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Enumeration



  1. Which of these are legacy classes?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Stack, Hashtable, Vector, Properties and Dictionary are legacy classes.