Create a hard mutliple choice question(4 choices) for this content: VAR-2.A.1 The use of…
- User
Create a hard mutliple choice question(4 choices) for this content: VAR-2.A.1 The use of array objects allows multiple related items to be represented using a single variable. VAR-2.A.2 The size of an array is established at the time of creation and cannot be changed. VAR-2.A.3 Arrays can store either primitive data or object reference data. VAR-2.A.4 When an array is created using the keyword new, all of its elements are initialized with a specific value based on the type of elements: § Elements of type int are initialized to 0 § Elements of type double are initialized to 0.0 § Elements of type boolean are initialized to false § Elements of a reference type are initialized to the reference value null. No objects are automatically created VAR-2.A.5 Initializer lists can be used to create and initialize arrays. VAR-2.A.6 Square brackets ([ ]) are used to access and modify an element in a 1D array using an index. VAR-2.A.7 The valid index values for an array are 0 through one less than the number of elements in the array, inclusive. Using an index value outside of this range will result in an ArrayIndexOutOfBoundsException being thrown.
- Assistant
Which of the following statements is true regarding the creation and manipulation of arrays in programming?
A. The size of an array can be dynamically changed at runtime after its creation.
B. When an array is initialized using the
newkeyword, elements of the type boolean are initialized totrue.C. Arrays cannot store primitive data types; they can only store object references.
D. Accessing an array element using an index value greater than or equal to the size of the array will result in an
ArrayIndexOutOfBoundsException.Correct Answer: D