Author | Message | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
rabbott
Posts: 1649
|
Posted 23:03 Mar 10, 2014 |
| ||||||||||||||||||
ladodgersfan
Posts: 13
|
Posted 15:36 Mar 11, 2014 |
what is the answer for question 5 i have b but it is marked wrong, i just want to make sure | ||||||||||||||||||
rabbott
Posts: 1649
|
Posted 16:58 Mar 11, 2014 |
Question 5. Which one of the following statements is correct for displaying the value in the second row and the third column of a two-dimensional, size 3 by 4 array, the one with the 'X'? _-_ _-_ _-_ _-_ _-_ _-_ _X_ _-_ _-_ _-_ _-_ _-_ System.out.println(arr[1][2]);
System.out.println(arr[2][3]); System.out.println(arr[2][1]); System.out.println(arr[3][2]); The correct answer is (a). The wording of the question ("second row and third column") suggests (b). That's why a diagram is also included. This question tests whether you know that array indexing starts at 0. An easy way to test this is to create an array and print the contents of those cells.
Last edited by rabbott at
17:08 Mar 11, 2014.
| ||||||||||||||||||
ytsai8
Posts: 47
|
Posted 19:59 Mar 11, 2014 |
@LADODGERSFAN You probably forgot the indexes are starting with [0].. :\ |