Page 403 - CA_Blue( J )_Class10
P. 403

9.  Which of the following represents the second element of the second row in a multi-dimensional array?
                       a.  arr[0][1]                                   b.  arr[0][0]
                       c.  arr[1][0]                                   d.  arr[1][1]
                   10.  Consider the following code:
                       int ar1[] = {1, 2, 3, 4, 5};
                       int a = 1;
                       for(int i = 0; i < 5; i++)
                       {
                            a = a + i * ar1[i];
                       }
                       System.out.println(a);
                       Which of the following will be the final value of a?
                       a.  35                                          b.  50
                       c.  0                                           d.  41
                    11.  What is an array in Java?
                       a.  A collection of elements of the same type arranged in sequential order.
                       b.  A collection of elements of different types.
                       c.  A single variable that holds multiple values.
                       d.  A data structure used to store key value pairs.
                   12.  Which of the following statements is true about Java arrays?
                       a.  Arrays in Java can dynamically resize.
                       b.  Arrays in Java can hold elements of different data types.
                       c.  The size of an array must be specified at the time of declaration.
                       d.  Arrays in Java cannot be passed as arguments to methods.
                   13.  How do you access elements in a one dimensional array in Java?
                       a.  Using dot notation                          b.  Using array index enclosed in square brackets
                       c.  Using arrow notation                        d.  Using parentheses
                   14.  Which of the following is the correct way to declare an array in Java?
                       a.  int[] myArray;                              b.  myArray[] int;
                       c.  Array myArray;                              d.  None of these
                   15.  What is the length of an array in Java?
                       a.  It is the total number of elements in the array.   b.  It is always fixed at 10.
                       c.  It is the number of dimensions of the array.   d.  All of these
                  Answers
                    1. a      2. a      3. b      4. d      5. a   6. b   7. b   8. c   9. d    10. d
                  11. a    12. c   13. b    14. a   15. a

                 B.  Fill in the blanks.

                    1.  The ………………… element is represented by a[10].
                    2.  An array element is accessed through ………………….
                    3.  An array is a ………………… data type.
                    4.  Index of 1st array element is ………………….
                    5.  The ………………… attribute is used to find the number of elements in the array.
                    6.  The length of the array, names[] = {"Anshu", "Sonam", "Ankita", "Anurag", "Abhi"}; is ………………….
                    7.  The value 12 is on the ………………… index in the array, arr[] = {23, 2, 43, 65, 78, 98, 12}.
                    8.  When we delete an element from an array, the last element will be replaced by ………………….

                  Answers
                                                                                                    th
                  1. 11       2. subscript    3. composite    4. 0      5. Length      6. 5      7. 6        8. 0
                      th





                                                                                                                       401
                                                                                                              Arrays   401
   398   399   400   401   402   403   404   405   406   407   408