A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

1. Which of these standard collection classes implements a dynamic array?
a. AbstractList
b. LinkedList
c. ArrayList
d. AbstractSet
View Answer Report Discuss Too Difficult!
Answer: (c).ArrayList

2. Which of these class can generate an array which can increase and decrease in size automatically?
a. ArrayList()
b. DynamicList()
c. LinkedList()
d. MallocList()
View Answer Report Discuss Too Difficult!
Answer: (a).ArrayList()

3. Which of these method can be used to increase the capacity of ArrayList object manually?
a. Capacity()
b. increaseCapacity()
c. increasecapacity()
d. ensureCapacity()
View Answer Report Discuss Too Difficult!
Answer: (d).ensureCapacity()

4. Which of these method of ArrayList class is used to obtain present size of an object?
a. size()
b. length()
c. index()
d. capacity()
View Answer Report Discuss Too Difficult!
Answer: (a).size()

5. Which of these methods can be used to obtain a static array from an ArrayList object?
a. Array()
b. covertArray()
c. toArray()
d. covertoArray()
View Answer Report Discuss Too Difficult!
Answer: (c).toArray()

6. Which of these method is used to reduce the capacity of an ArrayList object?
a. trim()
b. trimSize()
c. trimTosize()
d. trimToSize()
View Answer Report Discuss Too Difficult!
Answer: (d).trimToSize()

7. What is the output of this program?
    import java.util.*;
    class Arraylist 
    {
        public static void main(String args[]) 
        {
            ArrayList obj = new ArrayList();
            obj.add("A");
            obj.add("B");
            obj.add("C");
            obj.add(1, "D");
            System.out.println(obj);
        }
    }
a. [A, B, C, D].
b. [A, D, B, C].
c. [A, D, C].
d. [A, B, C].
View Answer Report Discuss Too Difficult!
Answer: (b).[A, D, B, C].

8. What is the output of this program?
    import java.util.*;
    class Output 
    {
        public static void main(String args[]) 
        {
            ArrayList obj = new ArrayList();
            obj.add("A");
            obj.add(0, "B");
            System.out.println(obj.size());
        }
    }
a. 0
b. 1
c. 2
d. Any Garbage Value
View Answer Report Discuss Too Difficult!
Answer: (c).2

9. Map implements collection interface?
a. True
b. False
c. May be
d. Can't say
View Answer Report Discuss Too Difficult!
Answer: (b).False

10. Which of the below does not implement Map interface?
a. HashMap
b. Hashtable
c. EnumMap
d. Vector
View Answer Report Discuss Too Difficult!
Answer: (d).Vector

Page 1 of 18