Page 253 - CA_Blue( J )_Class10
P. 253

16.  Write a menu-driven program using overloading method, word() to do the following:
                        a.  String word(String w)  -  reverses the word and returns the reversed word
                          Say, w= INDIA
                          Output AIDNI
                        b.  int word(String w, char ch) -  returns the number of vowels present in the word that is passed in char ch.
                          Say, w= INDIA, CH = 'I'
                          Output : 2
                   17.  Write a menu-driven program using overloading method, palindrome() to do the following:
                        a.   void palindrome(String)  -  Checks whether the word is a Palindrome or not.
                           Say, Input : MadaM
                           Output: MadaM is a Palindromic word
                        b.  void palindrome(int)   -   Checks whether the number is a Palindrome or not.
                           Say, Input: 121
                           Output: 121 is a Palindromic number
                   18.  Using the Overloading method, series() to do the following:
                        a.  int series (int n) - returns the sum of the series
                                    3
                                2
                             1
                                       4
                                           5
                          s= 1  + 2  + 3  + 4  + 5  + ……+ n
                                                  n
                        b.  void series (int x, int n) - print the sum of the series:
                          s= (x-1) + (x-3) + (x-5) + …….n  term
                                                th
                        c.  double series (double n) -  print the following series:
                          1, 4, 9, 16, 25,……… n  term
                                          th
                   19.  Design a class to overload a method show() as follows:
                        a.  double show(double n) - where n is the last term and returns result
                                                             th
                          result = 1/4 + 4/8 + 9/12 + 16/16 + 25/20….. n  term
                        b.  double show(double a, double n) - where n is the last value and a is a value and returns the sum
                          sum = 2/10 + 4/20 + 6/30 + 8/40 …….. n/5n
                          Do the above program using switch case.
                                             Previous Years' Questions




                                                              SECTION A

                    1.  Parameters used in the method call statement are ………………….                                   [2022]
                       a.  Actual parameters                           b.  Informal parameters
                       c.  Formal parameters                           d.  Void parameters
                   Ans.  a
                    2.  State whether the statement is True or False:
                        System.exit(0) terminates the program from any point.                                       [2022]
                       a.  True                                        b.  False
                   Ans.  a

                    3.  Given below is a class with following specifications:                                       [2022]
                       class name      :  Number
                       void Display(int n)  -   To extract and print each digit of given number from last digit of the first digit on separate lines.
                                         Example: n=674
                                         Output
                                         4
                                         7
                                         6
                        void Display()   -   To print numbers from 0.5 to 5.0 with updation of 0.5.




                                                                                                                       251
                                                                                                 User-defined Methods   251
   248   249   250   251   252   253   254   255   256   257   258