Menu
Question Index
...

What will be the output of the program?

public class DailyDoseC {
    public static void main(String[] args) {
        String inputString = "reactwall";
        char characters[] = inputString.toCharArray();
        System.out.print(meth(characters));
    }
    private static String meth(char[] input) {
        int totalIndex = input.length;
        int writeIndex = 1;
        if (input[0] == 'b') {    writeIndex = 0;    }
        for (int i = 1; i < totalIndex; ++i) {
            if (input[i] == 'b') {    continue;    }
            if (input[i] == 'c') {
                if (input[writeIndex - 1] == 'a') {
                    writeIndex--;
                    continue;
                }
            }
            input[writeIndex] = input[i];
            writeIndex++;
        }
        return new String(input, 0, writeIndex);
    }
}


reactwall
retwll
retwall
Compilation Error or Runtime Error.
None of the above.

Doubts

Problems

Topic: Unknown

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App