Menu
Question Index
...

What will be the output of the following program?

public class Vinayak {
    static int laddu = 4;
    final static String TRUTH = "GaneSh iS soO great";
    static String trunk = "";
    static float mouse = 12.0f;
    public static void main(String[] args) {
        ganesh();
        ganesh();
        ganesh();
        ganesh();
        ganesh();
        ganesh();
        System.out.println(trunk);
    }
    public static void ganesh() {
        vignesh(laddu);
        switch (laddu) {
            case 5 * 3 :
            case 18 :
                laddu -= 3;
                break;
            case ((int) mouse) :
                laddu = 2;
                break;
            default :
                laddu = TRUTH.length() - 1;
                break;
            case 2 :
                laddu = 0;
        }
    }
    public static void vignesh(int i) {
        trunk += TRUTH.charAt(i);
    }
}


StrOnG
Str nG
strong
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: charAt() Method In Java - Java Character Extraction

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App