Page 405 - CA_Blue( J )_Class10
P. 405

Declaration: int[] myArray; // Declaration
                        Initialization: myArray = new int[5]; // Initializing array with size 5
                        Two-dimensional Arrays: Two-dimensional arrays are arrays of arrays, representing data in rows and columns.
                        Declaration: int[][] my2DArray; // Declaration
                        Initialization: my2DArray = new int[3][3]; // Initializing 3x3 array
                    1.  What type of array stores elements in a single row or single column?
                       a.  One-dimensional Arrays                      b.  Two-dimensional Arrays
                       c.  Multi-dimensional Arrays                    d.  Arrays of Objects
                    2.  What is the correct syntax for declaring a one-dimensional array in Java?
                       a.  int[] myArray;                              b.  int[][] myArray;
                       c.  int myArray[][];                            d.  int myArray[];
                    3.  How do you initialize a one-dimensional array with size 5?
                       a.  myArray = new int(5);                       b.  myArray = new int[] {5};
                       c.  myArray = new int[5];                       d.  myArray = new int[5]();
                    4.  Which type of array represents data in rows and columns?
                       a.  One-dimensional Arrays                      b.  Two-dimensional Arrays
                       c.  Multi-dimensional Arrays                    d.  Arrays of Objects
                   Ans.  1. a   2. a   3. c   4. b


                      Unsolved Questions



                 A.  Tick ( ) the correct answer.
                    1.  Which of the following operation can be done on arrays?
                       a.  Insertion                                   b.  Deletion
                       c.  Sorting                                     d.  All of these
                    2.  The "int ar[][]=new int[3][4];" is used to create an array of size ………………… .
                       a.  3 × 3                                       b.  3 × 4
                       c.  4 × 3                                       d.  4 × 4
                    3.  What is the value of a after executing the following code?
                       int arr[]={1,2,3,4,5};
                       a=arr[1]+arr[4] - arr[2];
                       a.  5                                           b.  2
                       c.  1                                           d.  4
                    4.  Which of the following is the last subscript of N element array?
                       a.  N                                           b.  N+1
                       c.  N-1                                         d.  None of these
                    5.  If int arr[]={1,3,5,7,5}; then what is the value of a, if a=arr.length+arr[4]?
                       a.  12                                          b.  5
                       c.  10                                          d.  0
                    6.  How do you initialize an array in Java?
                       a.  int[] myArray = new int();                  b.  int[] myArray = new int[5];
                       c.  int[] myArray = {1, 2, 3, 4, 5};            d.  All of these
                    7.  What happens if you try to access an index beyond the array bounds in Java?
                       a.  It throws a compiletime error.
                       b.  It throws a runtime error.
                       c.  It returns the default value for that data type.
                       d.  It returns null.
                    8.  Which method is used to find the length of an array in Java?
                       a.  size()                                      b.  length()
                       c.  getSize()                                   d.  getLength()


                                                                                                                       403
                                                                                                              Arrays   403
   400   401   402   403   404   405   406   407   408   409   410