Menu
Question Index
...

What will be the output of the following program?

public class XYZ {

    public static void main(String args[]) {
        char array[] = {'a', 'b', 'c', 'd'};
        for (char element : array) {
            for (char result : array) {
                System.out.print(element + "~" + result);
            }
        }
    }
}


a~ab~ac~ad~aa~bb~bc~bd~ba~cb~cc~cd~ca~db~dc~dd~d
a~aa~ba~ca~db~ab~bb~cb~dc~ac~bc~cc~dd~ad~bd~cd~d
a~ab~bc~cd~da~ab~bc~cd~da~ab~bc~cd~da~ab~bc~cd~d
aa~ab~ac~ad~ba~bb~bc~bd~ca~cb~cc~cd~da~db~dc~dd~
Compilation Error or Runtime Error

Doubts

Problems

Topic: For-each Loop In Core Java Programming

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App