Menu
Question Index
...

What will be the output of the following program?

public class LoopsAreSimple {

    public static void main(String[] args) {
        char c = 'A';
        int i = 0;
        for (; i < 4; i++, m(i, c)) {
            c += i;
        }
        m(i, c);
    }

    private static void m(int i, char c) {
        for (int j = 0; j < i; j++) {
            System.out.print(c);
        }
    }
}


ABBDDDGGGGKKKK
ABBDDDGGGGGGGG
BDDGGGKKKKKKKK
Some other output or Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Methods - Parameter Passing And Scope

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App