Menu
Topics Index
...
`

Array creation and declaration


If you need explanation Read this topic

If you need Answer Take test on this topic

Array creation and declaration
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);
    }
}

A. Length = 4
Word = SSA
Values = 11 33 0
B. Length = 4
Word = MSD
Values = 0 0 0
C. Length = 4
Word = SSA
Values = 0 0 0
D. Length = 4
Word = MSD
Values = 11 33 0
E. Some other output
F. Compilation Error or Runtime Error
Topic: Java String Arrays - String Arrays In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

option a is the answer...it just simply prints the length of s1 and the word SSA and then the values a1[0],a1[2] an a1[3]

Posted by Bhanu Teja    2013-07-04 03:05:24


option A as we r creating arrays of strings and arrays of object Ademos.. and then printing length of array string -4 and printing s1[3] "SSA" and finally printing the values i of Ademos which are 11 33 0

Posted by Shaik Nyamath    2013-07-04 03:43:33


Congratulations Krishna Bhanu Teja. You are this dose winner. Please send us your mobile details and we will process the recharge asap.

Posted by Merit Campus    2013-07-05 11:51:08


got the rc thank you mc

Posted by Bhanu Teja    2013-07-21 15:01:08


© meritcampus 2019

All Rights Reserved.

Open In App