Menu
Topics Index
...
`

EnumSet


If you need explanation Read this topic

If you need Answer Take test on this topic

EnumSet
What will be the output of the following program?
import java.util.*;
public class Cap {
    enum DAYS {
        THU, FRI, SAT, SUN, MON, TUE, WED;
    }
    public static void main(String[] args) {
        EnumSet es = EnumSet.range(DAYS.THU, DAYS.MON);
        System.out.println(es);
        es.add(DAYS.TUE);
        System.out.println(es);
    }
}

A. [FRI, MON, SAT, SUN, THU]
[FRI, MON, SAT, SUN, THU, TUE]
B. [THU, FRI, SAT, SUN, MON]
[THU, FRI, SAT, SUN, MON, TUE]
C. [FRI, SAT, SUN]
[FRI, SAT, SUN, TUE]
D. Some other output
E. Compilation Error or Runtime Error
Topic: Java EnumSet

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans is B.
because the elements are stored as specified in the range and order is as defined in the enum.

Posted by Gopinath Manchikanti    2014-08-07 12:50:49


Congratulations Gopinath Manchikanti. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-08-08 04:30:34


© meritcampus 2019

All Rights Reserved.

Open In App