Menu
Topics Index
...
`

Array declaration1473


If you need explanation Read this topic

If you need Answer Take test on this topic

Array declaration1473
What will be the output of the following program?
public class DemoOnArrays
{
    public static void main(String args[])
    {
        int[] firstInput, secondInput;
        firstInput = new int[2];
        secondInput = 011;
        firstInput[0] = firstInput[1] = secondInput;
        System.out.print(firstInput[0] + firstInput[1]);
    }
}

A. 11
B. 22
C. 33
D. 55
E. Compilation Error or Runtime Error
Topic: Creating Array Of Objects 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.

ANS IS C

Posted by Vijay Kumar    2014-07-03 03:37:58


Ans is b as both values are 11 and adds to 22 and prints

Posted by Bharath Yelchuri    2014-07-03 03:56:35


b

Posted by Sri Devi Reddy    2014-07-03 04:07:29


E  Type Mismatch Error .Here it is declared     as array and used as int type  array cannot be converted to int , in the next step int values used as array values where type conversion is not possible  java.lang.Error

Posted by Aparna Lakshmi    2014-07-03 05:26:46


E

Posted by Rishav Seksaria    2014-07-03 06:05:35


e

Posted by Aboudi Sabbah    2014-07-03 06:38:08


Ans is E...For the array secondInput size is not declared and is assigned int value while it requires an array

Posted by Badam Swathi    2014-07-03 08:04:50


E

Posted by Rajashekar Jadala    2014-07-03 11:32:35


e

Posted by Elias Dblo    2014-07-03 18:27:12


Congratulations Aparna Lakshmi. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-07-04 04:32:15


© meritcampus 2019

All Rights Reserved.

Open In App