Quiz: Array

To View Tricks: Login Required

Number of Questions: 9

Question: 6 -

Which of the following is advantage of java array?

Options:
  1. Both Code Optimization and Random access

  2. Code Optimization

  3. Random access

  4. Size No-Limit

  5. Answer:

    Both Code Optimization and Random access

    Solution not available.

Question: 7 -

We can calculate the length of an array using ________.

Options:
  1. array.sizeof()

  2. sizeof(array)

  3. array.len

  4. array.length

  5. Answer:

    array.length

    Solution:

    We can calculate the length of an array using array.length.


Question: 8 -

Which of the following is used to declare,construct, and initlaize an array?

Options:
  1. int [] arr = (1, 2, 3);

  2. int [] arr = {};

  3. int arr [] = {1, 2, 3};

  4. int arr [] [] = {1, 2, 3, 4};

  5. Answer:

    int arr [] = {1, 2, 3};

    Solution:

    int arr [] = {1, 2, 3}; is used to declare,construct, and initlaize an array becuase Option A is wrong because it initializes an int array with String literals. Option B is wrong because it uses something other than curly braces for the initialization. Option C is wrong because it provides initial values for only one dimension, although the declared array is a two-dimensional array.


Question: 9 -

In java, array elements are stored in ________ memory locations.

Options:
  1. Sequential

  2. Random

  3. Sequential & Random

  4. Binary search

  5. Answer:

    Sequential

    Solution:

    Array elements are stored in contiguous memory. Linked List is stored in random memory locations.