Question:

int marks[] = {90, 60, 70, 65, 80
From the above given Java statement which of the following value is returned by int marks[4]? 
 

Show Hint

Java arrays use {zero-based indexing}, meaning the first element starts at index 0.
  • 60
  • 70
  • 65
  • 80
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

Step 1: Understanding array indexing in Java.
In Java, arrays follow the concept of zero-based indexing. This means that the first element of the array starts at index 0.
Therefore, the elements of the array will be stored as follows:
marks[0] = 90
marks[1] = 60
marks[2] = 70
marks[3] = 65
marks[4] = 80
Step 2: Finding the requested element.
The question asks for the value stored at marks[4]. According to the indexing shown above, the value at position 4 is 80.
Step 3: Evaluation of options.
(A) 60: Incorrect. This is the value at index 1.
(B) 70: Incorrect. This is the value at index 2.
(C) 65: Incorrect. This is the value at index 3.
(D) 80: Correct. This is the value stored at index 4.
Step 4: Conclusion.
Thus, the value returned by marks[4] is 80.
Final Answer: 80
Was this answer helpful?
0
0