Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class BitsAre {
    public static void main(String[] args) {
        BitSet bs = new BitSet();
        for (String s : new String[]{"LeaRn", "PracTice", "coMpetE"}) {
            for (int i = 0; i < s.length(); i++) {
                if (Character.isLowerCase(s.charAt(i)))
                    bs.set(i);
            }
            System.out.println(bs);
        }
    }
}


{1, 2, 4}
{1, 2, 3, 5, 6, 7}
{0, 1, 3, 4}
{1, 2, 4}
{1, 2, 3, 4, 5, 6, 7}
{0, 1, 2, 3, 4, 5, 6, 7}
{1, 2, 4}
{1, 2, 3, 5, 6, 7}
{0, 1, 3, 4, 6, 7}
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java BitSet

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App