Page 408 - CA_Blue( J )_Class10
P. 408

Ans.  The outputs is:
                     (i)  Big data
                     (ii) 4
                  3.  Differentiate between searching and sorting.                                                [2018]
                Ans.                    Searching                                       Sorting
                     Finding an element in the array.                Arranging the array elements in ascending or descending
                                                                     order.
                     Two types of searching are: Linear search and Binary search.  Two types of sorting are: Bubble sort and Selection sort.

                  4.  String x[] = {"SAMSUNG", "NOKIA", "SONY", "MICROMAX", "BLACKBERRY"};
                     Give the output of the following statements:                                                 [2017]
                    (i)  System.out.println(x[1]);                  (ii)  System.out.println(x[3].length());
                Ans.  (i)  NOKIA                                    (ii)  8
                  5.  If int x[] = {4, 3, 7, 8, 9, 10}; what are the values of p and q?                           [2016]
                    (i)  p = x.length                               (ii)  q = x[2] + x[5] * x[1]
                Ans.  (i)  6                                        (ii)  7 + 10 * 3
                                                                       = 7 + 30
                                                                       = 37
                  6.  What will this code print?                                                                  [2015]
                    int arr[] = new int[5];
                    System.out.println(arr);
                    (i)  0                                          (ii)  value stored in arr[0]
                    (iii) 0000                                     (iv)  garbage value
                Ans.  garbage value
                  7.  Find the errors in the given program segment and re-write the statements correctly to assign values to an integer array.    [2014]
                    int a = new int(5);
                    for(int i = 0; i <= 5; i++) a[i] = i;
                Ans:  int a[] = new int[5];
                          for(int i = 0; i < 5; i++)
                               a[i] = i;
                  8.  Write statements to show how finding the length of a character array char ch[] differs from finding the length of a
                    String object str.                                                                            [2013]
                Ans.  To find the length of a char array ch[] :

                    int len = ch.length;
                    To find the length of a String str :
                          len = str.length();
                  9.  If int n[] = {1, 2, 3, 5, 7, 9, 13, 16};
                     What are the values of x and y?                                                              [2013]
                     x = Math.pow(n[4], n[2]);
                     y = Math.sqrt(n[5] + n[7]);
                Ans.  x = 343.0 and y = 5.0
                 10.  What is an array? Write a statement to declare an integer array of 10 elements.             [2012]
                Ans.  Array can be defined as set of variables contains values of same data types having same variable name but different subscripts
                    required to separate the values.
                    int ar[] = new int[10];
                 11.  Name the search or sort algorithm that:
                    (i)   Makes several passes through the array, selecting the next smallest item in the array each time and placing it where it
                       belongs in the array.
                    (ii)   At each stage, compares the sought key value with the key value of the middle element of the array.   [2012]
                Ans.  (i)  Selection Sort Algorithm.                (ii)  Binary Search Algorithm.



                406406  Touchpad Computer Applications-X
   403   404   405   406   407   408   409   410   411   412   413