My Report

Java Collections Test – 3


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. Which of these methods sets every element of a List to a specified object?

2. Which of these methods can randomize all elements in a list?

3. Which of these is true about unmodifiableCollection() method?

4. Which of these methods can convert an object into a List?

5. Which of these is an incorrect form of using method max() to obtain a maximum element?

6. What will be the output of the following Java program?

 
    import java.util.*;
    class Collection_Algos 
    {
        public static void main(String args[]) 
        {
            LinkedList list = new LinkedList();
            list.add(new Integer(2));
            list.add(new Integer(8));
            list.add(new Integer(5));
            list.add(new Integer(1));
            Iterator i = list.iterator();
	    while(i.hasNext())
	        System.out.print(i.next() + " ");
        }
    }

7. What will be the output of the following Java program?

 
    import java.util.*;
    class Collection_Algos 
    {
        public static void main(String args[]) 
        {
            LinkedList list = new LinkedList();
            list.add(new Integer(2));
            list.add(new Integer(8));
            list.add(new Integer(5));
            list.add(new Integer(1));
            Iterator i = list.iterator();
            Collections.reverse(list);
	    while(i.hasNext())
	        System.out.print(i.next() + " ");
        }
    }

 

Start practicing “1000 MCQs on Java”, and once you are ready, you can take tests on all topics by attempting our “Java Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.