The maximum number of elements in the array is defined in the program.
上限 means 'upper limit' or 'cap' and is used in broader contexts (e.g., budget, speed), whereas 最大数 is more technical and numeric.
Compound of 最大 (maximum) + 数 (number). A straightforward technical term.