Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

An inexperienced Java programmer writing software for the recent elections assum

ID: 3656844 • Letter: A

Question

An inexperienced Java programmer writing software for the recent elections assumed that no more than 1000 people would vote on any given voting machine during any given election, so he made an array of length 1000 in which to store the votes. However, the large turnout meant that the voting machines were used for longer periods of time than expected and some malfunctioned because they received more than 1000 votes. What would have been a better way to store the votes than using a Java array? Why? provide good justification for why your suggestion is better than using the array to hold the votes

Explanation / Answer

use LinkedList or ArrayList instead of array, becoz for storing the data in array we have to declare the array of fixed length at the time of declaration but in case of linkedlist and arraylist new space is created dynamically. so both are better than array.