Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class EnjoyFully {
    public static void main(String[] args) {
        Integer[] a = new Integer[]{1, 2, 3, 4, 5};
        Integer[] b = new Integer[]{2, 3, 1, 0, 5};
        Character[] c = new Character[]{'a', 'b', 'c', 'd', 'e'};
        Character[] d = new Character[]{'e', 'a', 'd', 'C', 'a'};
        Boolean[] e = new Boolean[]{true, false, true, true, false};
        Boolean[] f = new Boolean[]{true, false, false, true, false};
        Set setA = new HashSet<>(Arrays.asList(a));
        Set setB = new HashSet<>(Arrays.asList(b));
        Set setC = new HashSet<>(Arrays.asList(c));
        Set setD = new HashSet<>(Arrays.asList(d));
        List listE = new ArrayList<>(Arrays.asList(e));
        List listF = new ArrayList<>(Arrays.asList(f));
        Set setG = new HashSet<>(Arrays.asList(e));
        Set setH = new HashSet<>(Arrays.asList(f));
        setB.removeAll(setA);
        setC.removeAll(setD);
        listE.removeAll(listF);
        setG.removeAll(setH);
        System.out.print(setB + ", ");
        System.out.print(setC + ", ");
        System.out.print(setG + ", ");
        System.out.print(listE);
    }
}


[0], [b, c], [], []
[0], [b], [], []
[0], [b, c], [], [false]
[0], [b, c], [false], [false]
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Collection Framework In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App