Menu
Topics Index
...
`

Tango array


If you need explanation Read this topic

If you need Answer Take test on this topic

Tango array
What will be the output of the following program?
public class Tango
{
    public static void main(String[] args)
    {
        int[] print = new int[]{0, 1, 2, 3, 4, 5};
        System.out.print("\"Prints = ");
        System.out.print(print[0] + print[5] + print[2] + "\"");
    }
}

A. "Prints = 052"
B. "Prints = 7"
C. \"Prints = 7\"
D. Compilation Error
E. Runtime Error
Topic: Java Array Initialization

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.

B is t ans. as 0+5=2 is 7 so B is ans.

Posted by Shabaaz Shaikz    2014-08-28 12:43:40


Ans:B in first sop statement it prints "prints=  and sop prints 7" then it prints  "prints=7"

Posted by Indrasena Reddy    2014-08-28 12:47:42


B

Posted by Rayapudi Ramya    2014-08-28 13:04:36


B

Posted by Mark Kovach    2014-08-28 13:25:41


a.here + is actng as a concatenaton oprtr n not arthmetic

Posted by Shamee Shamee    2014-08-29 03:50:40


B ,, bcoz here 0,5,2 are in without " " so they are added...

Posted by Raju VarshnEy    2014-08-29 12:30:55


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

Posted by Merit Campus    2014-09-01 06:03:36


© meritcampus 2019

All Rights Reserved.

Open In App