Menu
Question Index
...

What will be the output of the following program?

public class Active {
    public static void main(String[] args) {
        if (true) {
            int[] str = {5};
            String i = "" + str[0];
            System.out.print(i);
        }
        System.out.print("-");
        {
            int[] str = {1, 2};
            System.out.print(str[1]);
        }
        System.out.print("-");
        {
            String str = "I like Java Programming Language";
            System.out.print(str);
        }
        System.out.print("-");
        {
            int str = 124;
            System.out.print(str);
        }
    }
}


5-2-I like Java Programming Language-124
5-5-I like Java Programming Language-5
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Array Initialization

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App