Question:

The sales made by 5 salesmen selling 5 products is stored in a two-dimensional array of integer data type. How many bytes does the array occupy?

Show Hint

For array memory questions, first find the total number of elements, then multiply by the size of one element. For an \textbf{int} in Java, always use \(4\) bytes.
  • 25
  • 200
  • 50
  • 100
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is D

Solution and Explanation

Step 1: Find the total number of elements in the two-dimensional array.
The question says that the sales data of \(5\) salesmen and \(5\) products is stored in a two-dimensional array. This means the array has: \[ 5 \times 5 = 25 \] elements in total.
So, the array contains \(25\) integer values.
Step 2: Recall the memory occupied by one integer.
In Java, an int data type occupies \(4\) bytes of memory.
Therefore, each element of the array will take: \[ 4 \text{ bytes} \] Step 3: Calculate the total memory occupied.
Since there are \(25\) integer elements, total memory occupied by the array is: \[ 25 \times 4 = 100 \] bytes.
Step 4: Match the answer with the given options.
  • (A) 25: Incorrect, this is only the number of elements.
  • (B) 200: Incorrect.
  • (C) 50: Incorrect.
  • (D) 100: Correct.
Hence, the array occupies 100 bytes.
Final Answer:\(100\) bytes.
Was this answer helpful?
0
0

Questions Asked in ICSE Class X board exam

View More Questions