Menu
Question Index
...

What will be the output of the following program?

public class Ademos {
    int i = 0;
    public static void main(String[] args) {
        String s1[] = {"abc", "xyz", "MSD", "SSA"};
        Ademos a1[] = {new Ademos(), new Ademos(), new Ademos()};
        System.out.println("Length = " + s1.length);
        System.out.println("Word = " + s1[3]);
        a1[0].i = 11;
        a1[1].i = 22 + a1[0].i;
        System.out.print("Values = " + a1[0].i + " " + a1[1].i + " " + a1[2].i);
    }
}


Length = 4
Word = SSA
Values = 11 33 0
Length = 4
Word = MSD
Values = 0 0 0
Length = 4
Word = SSA
Values = 0 0 0
Length = 4
Word = MSD
Values = 11 33 0
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java String Arrays - String Arrays 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