Machine-translated by Google. Questions are authored in English.
Top

Discussion

In most modern programming languages like Java, what is the 'in an array' ?

  • A.1
  • B.-1
  • C.0
  • D.Depends on language

Answer: C

The answer is 0.

The printed stem leaves out the thing it asks about (it reads 'what is the 'in an array''), but the options and the Commission's key show the intended question: in Java, and in most modern languages, the first element of an array is at index 0, so the starting index is 0.

An index of 1 is used by some older or specialised languages (Fortran and MATLAB count from 1). A negative index such as -1 is not a valid Java array index and throws an exception. 'Depends on language' is true of languages in general, but the question names Java and 'most modern' languages, and for these the answer is 0.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.