This grid shows the state of a 2D array: The grid is created with this code: Which line of code, when inserted in place of //line n1, adds an X into the grid so that the grid contains three consecutive XS?
The correct answer is A. The answer D will return an exception because there is no way to access the 3rd place. Always remember that Java indexes from 0, to make a complete line of X we need to put an X in the second place from the third line and I say again, as java indexes from 0, so it is grid[2][1] = 'X';
The answer can't be D as 3 goes out of bounds of array, answer is A
upvoted 3 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
MPignaProTech
5 months, 2 weeks agodsms
1 year, 7 months agodsms
1 year, 7 months agodsms
1 year, 7 months agoakbiyik
2 years, 4 months agoiSnover
2 years, 5 months agoshivkumarx
2 years, 6 months ago