0
Guys does anyone know the answer on java's array module 3 question 2
9 ответов
+ 9
Uhhh 2?
+ 5
This one?
What is the output of this code?
int tmp[ ] = {5, 8, 9, 3};
System.out.println(tmp[2]);
Remember arrays are 0 based
tmp[2] is asking for the element in the 2 position of the tmp array
//0 1 2 3
{5, 8, 9, 3};
The int 5 is the element in the 0 position of the tmp array.
So, without straight up giving you the answer, I hope this helps you to understand and figure it out.
+ 2
Answer=9
Because the elements in the array are identified with zero-based index numbers, meaning that the first element's index is 0 rather than one.
For example:- The maximum index of the array int[5] is 4.
In this question
int tmp[]={5,8,9,3};
System.out.println(tmp[2]);
//0 1 2 3
{ 5,8,9,3};
The integer value 9 is situated at the position of 2
tmp[2]Is asking for the element in the 2nd position of the tmp array. So the answer is 9
+ 1
9
0
9?
0
9
0
What is the output of this code?
int tmp[ ] = {5, 8, 9, 3};
System.out.println(tmp[2]);
0
int sum1 = 100 + 50;
int sum2 = sum1 + 250;
int sum3 = sum2 + sum2;
System.out.println(sum3);
What will be the final output?
0
int x = 10;
x = x + 5;
System.out.println(x);
What will be the output?