Computer Science, asked by upomabiswas, 1 year ago

give the output : int m[]={2,4,6,8}; System.Out.Println(m[1]+" "+m[2]); and please explain it...I will mark you as the brainliest !!!


Akshat999: class isnt required here... its just a simple finding the output problem... just need to find the output here from the given instruction
Akshat999: ohhkk...^_^'

Answers

Answered by Akshat999
25
Hi,
The answer will be 4 6...bcoz m[0] is 2,m[1] is 4 and so on.... The two commas denote an blank space...

isabella4: H.F.D
Akshat999: Happy friendship day..
isabella4: ty to u too
isabella4: again....lol
Answered by Anonymous
14

Hi,

in this line of code int m[]={2,4,6,8}; we are making an array m which has value of {2,4,6,8}.

as you know array's are 0 index based, if we have to fetch 2 from array m then we have to write it like this m[0] because 2 is at the index of 0

hope you understood.

here is the program

import static java.lang.System.out;

public class testingProgram{

public static void main(String []args){

int m[]={2,4,6,8};

System.out.println(m[1]+" "+m[2]);

}

}

and the output would be 4 6 because in this statement m[1]+" "+m[2] we are fetching values of index 1 and index 2 so the output would be 4 6

notice there would be space between them because we have concated them with the help of " " space.

Similar questions