Page 255 - CA_Blue( J )_Class10
P. 255

}
                      void main() {
                      Student s = new (vi). ___
                      s.input();
                      s.merit();
                      s.display();
                      }
                      }
                       (i)   a. utility             b. Util                c. util.               d. UTILITY
                       (ii)  a. obj.nextDouble();   b. nextDouble();       c. obj.nextFloat();    d. nextFloat()
                       (iii)  a. per>=90            b. per<=90             c. per>90              d. per==90
                       (iv)  a. NOT A WARDED;       b. "NOT AWARDED";      c. "AWARDED";          d. "NOT A WARDED"
                       (v)  a. display()            b. Display()           c. Print()             d. DISPLAY()
                       (vi)  a. Student();          b. STUDENT()           c. student()           d. Student()
                   Ans.  (i) c     (ii) a      (iii) a     (iv) b      (v) a     (vi) a
                    5.  The following program segment checks whether number is an Abundant number or not. Anumber is said to be an Abundant
                        number when the sum of its factors (excluding the number itself) is greater than the number.  [2022]
                        Example: Factors of number 12 are 1,2,3,4,6
                        Sum of factors is 1+2+3+4+6 = 16
                        Fill in the blanks with appropriate java statements
                      void abundant(int n)
                      { int s=0;
                      for((i) ___ ;(ii) ___ ;i++)
                      { if((iii)___)
                      s=s+i;}
                      if((iv) __)
                      System.out.println("Abundant Number");
                      else
                      System.out.println("Not Abundant Number");
                      }
                       (i)   a. int i =1            b. int i=0             c. int i=2              d. Int i=1
                       (ii)  a. i<=n                b. i<n                 c. i>n                  d. i>=n
                       (iii)  a. n%i==0             b. n%i==1              c. n%2==0               d. n/2==0
                       (iv)  a. s<n                 b. s>n                 c. s==n                 d. s=n
                   Ans.  (i) a     (ii) b      (iii) a     (iv) b
                    6.  State a difference between call by value and call by reference.                             [2019]
                   Ans.                   call by value                                 call by reference

                        The copy of  the actual  parameters is  sent to the formal  The actual parameter and the formal parameter share the
                        parameter.                                      same location in the memory.
                        Any change in the formal parameter will not reflect on the  Any change in the formal parameter while the method is
                        actual parameter.                               executing, the actual parameter also changes.
                        Any type of primitive data can be used in call by value.   Only non-primitive data can be used in call by reference.
                    7.  Name the keyword which:
                       (i)  indicates that a method has no return type.
                       (ii) makes the variable as a class variable.                                                 [2019]
                   Ans.  (i)  void                                    (ii) static

                    8.  Write the prototype of a function check which takes an integer as an argument and returns a character.   [2018]
                   Ans.  The function prototype is:
                       char check(int num)





                                                                                                                       253
                                                                                                 User-defined Methods   253
   250   251   252   253   254   255   256   257   258   259   260