Page 333 - Computer science 868 Class 12
P. 333

b.  Two types of searching are: Linear search and Binary search.
                    5.  Write syntax to find the total number of elements in the array?
                   Ans.  Syntax:
                        int len= name_of_array.length;
                 D.  Assertion and Reasoning Based Question.
                    Assertion: Double-Dimensional array is also known as two-dimensional array.
                    Reason: The double-dimensional array stores data in a tabular format, thus containing rows and columns.
                    (a)  Both Assertion and Reason are true, and Reason is the correct explanation for Assertion.
                    (b)  Both Assertion and Reason are true, but Reason is not the correct explanation for Assertion.
                    (c)  Assertion is true and Reason is false.
                    (d)  Assertion is false and Reason is true.
                   Ans.  (a) Double-Dimensional array is also known as two-dimensional array. Unlike, single-dimensional array which contains only 1 row,
                       the double-dimensional array stores data in a tabular format, thus containing rows and columns.
                        A double-dimensional array uses a combination of rows and columns where the 1st index refers to the row position and the 2nd
                       index refers to the column position. It is also known as a Double Subscripted Value as it has two subscripts.

                      Unsolved Questions



                 A.  Tick ( ) the correct option:
                    1.  Which is correct syntax?
                       a.  String name[]=new String[25];               b.  string name[]=new string[25];
                       c.  String[] name=new String[];                 d.  String name[25]=new String[];
                    2.  for(i=0;i<6;i++)
                           {
                             ar[i]=sc.nextInt();
                           }
                       a.  Array contains 5 elements                   b.  Array contains 6 elements
                       c.  Array contains unlimited elements           d.  None of these
                    3.  ………………… is the first element in  the array.
                       a.  ar[1]                                       b.  ar[-1]
                       c.  ar[0]                                       d.  All of these
                    4.  char array[]={‘a','B','2','5',':'};
                       System.out.println(array[0]+array[2]);
                       The program snippet will print: …………………
                       a.  145                                         b.  146
                       c.  147                                         d.  150
                    5. int ar[]={1,2,3,4,5};
                       ar[2]=ar[4];
                       ar[4]=ar[1]+ar[0];
                       System.out.println(ar[2]+" "+ar[4]);
                       The program snippet will print: …………………
                       a.  5 4                                         b.  3 5
                       c.  5 3                                         d.  None of these

                 B.  Fill in the blanks:
                    1.  float  ar[][]=new float[2][4];  creates an array of ………………… datatype.
                    2.  if(n[i][j]%2 == 0 ) : It checks whether n[i][j] is an ………………… number or not.
                    3.  LB in address calculation stands for ………………… of an array.
                    4.  int ar[][]= new int[2][3]; creates an array of ………………… rows.
                    5.  The time of binary search is ………………… than the time of linear search.



                                                                                                                       331
                                                                                                              Arrays   331
   328   329   330   331   332   333   334   335   336   337   338