Menu
Question Index
...

What will be the output of the following program?

import java.util.BitSet;

public class LearnPracticeCompete {

    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);
                else
                    bs.flip(i);
            }
        }
        System.out.println(bs);
    }
}


{1, 2, 3, 4, 5, 6, 7}
{2, 6}
{0, 1, 2, 3, 4}
{0, 1, 3, 4, 5, 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