Menu
Question Index
...

What will be the output of the following program?

import java.util.*;

public class CollectionCheck
{
    public static void main(String args[])
    {
        List list = new ArrayList();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");

        Collection checkedList = Collections.checkedCollection(list, String.class);
        System.out.println("Checked list: " + checkedList);

        list.add(10);    //LINE K
        checkedList.add(10);    //LINE G
    }
}


Checked list: [one, two, three, four, 10]
Checked list: [one, two, three, four, 10]
Throws an exception at LINE K
Throws an exception at LINE G
Compilation Error for some other reason or Runtime Error

Doubts

Problems

Topic: Java Collection Algorithms

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App