0

Guys does anyone know the answer on java's array module 3 question 2

14th Jul 2017, 2:54 AM
Uzodimma Samuel
Uzodimma Samuel - avatar
9 ответов
+ 9
Uhhh 2?
14th Jul 2017, 3:18 AM
MrCoder
MrCoder - avatar
+ 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.
14th Jul 2017, 3:30 AM
ChaoticDawg
ChaoticDawg - avatar
+ 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
5th Apr 2021, 12:01 PM
Shailo Joy . A . J
Shailo Joy . A . J - avatar
+ 1
9
29th Jun 2022, 12:11 AM
Opanuga Stephen
Opanuga Stephen - avatar
0
9?
14th Jul 2017, 4:12 AM
King Boogz
King Boogz - avatar
0
9
22nd Oct 2020, 12:00 AM
Kalkidan Abebe
Kalkidan Abebe - avatar
0
What is the output of this code? int tmp[ ] = {5, 8, 9, 3}; System.out.println(tmp[2]);
9th Dec 2020, 2:43 AM
Fakhrul Azim
Fakhrul Azim - avatar
0
int sum1 = 100 + 50; int sum2 = sum1 + 250; int sum3 = sum2 + sum2; System.out.println(sum3); What will be the final output?
9th Dec 2020, 2:51 AM
Fakhrul Azim
Fakhrul Azim - avatar
0
int x = 10; x = x + 5; System.out.println(x); What will be the output?
9th Dec 2020, 2:53 AM
Fakhrul Azim
Fakhrul Azim - avatar