Menu
Question Index
...

What will be the output of the following program?

public class HappyVijayaDasami {

    public static void main(String[] args) {
        String[] greetings = {"Hoppy", "Vijoyo", "Dasami"};
        int i = 0;
        while (i < greetings.length) {
            print(i, greetings[i++]);
        }
    }

    private static void print(int i, String string) {
        switch (i) {
            default :
                string = string.replace('o', 'a');
            case 1 :
                string = new StringBuffer(string).reverse().toString();
                break;
            case 2 :
                string = string.toUpperCase();
                break;
        }
        System.out.print(string + " ");
    }
}


Happy Vijaya DASAMI
yppaH oyojiV DASAMI
Happy oyojiV DASAMI
Some other output or Compilation Error

Doubts

Problems

Topic: Conclusion Of Strings 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