Page 675 - Computer science 868 Class 12
P. 675

(ii)  Verify if the following proposition is valid using the truth table:
                          A => ( B ∧ C )  = ( A => B ) ∧ ( B => C )                                                    [3]
                     (iii)  How is a 2 to 4 decoder related to 4:1 multiplexer?                                        [2]

                                                               SECTION – B
                                                          Answer any two questions.
                                Each program should be written in such a way that it clearly depicts the logic of the problem.
                                      This can be achieved by using mnemonic names and comments in the program.
                                                   (Flowcharts and Algorithms are not required.)
                                                      The programs must be written in Java.


                 Question 6.
                 An Evil Number is a number which contains even number of 1’s in its binary equivalent.
                 Example:   Binary equivalent of 10 = 1010 which contains even number on 1’s.
                          Thus, 10 is an Evil Number.
                 Design a class Evil to check if a given number is an Evil number or not. Some of the members of the class are given below:      [10]
                 Class name                                    :  Evil
                 Data members/instance variables:
                 num                                           :  to store a positive integer number
                 bin                                           :  to store the binary equivalent
                 Methods / Member functions:
                 Evil( )                                       :  default constructor to initialise the data member with legal initial value
                 void  acceptNum( ) void rec_bin (int x)       :  to accept a positive integer number

                 void  check( )                                :   to convert the decimal number into its binary equivalent using recursive
                                                                 technique
                                                               :   to check whether the given number is an Evil number by invoking the
                                                                 function rec_bin() and  to display the result with an appropriate message
                 Specify the class Evil giving details  of the constructor(), void acceptNum(), void rec_bin(int) and void check(). Define a main() function to
                 create an object and call all the functions accordingly to enable the task.

                 Question 7.
                 A class Composite contains a two-dimensional array of order [m x n]. The maximum values possible for both ‘m’ and ‘n’ is 20. Design a
                 class Composite to fill the array with the first (m x n) composite numbers in column wise.
                 [Composite numbers are those which have more than two factors.]
                 The details of the members of the class are given below:
                 Class name                                    :  Composite
                 Data members/instance variables:
                 arr[ ] [ ]                                    :  integer array to store the composite numbers column wise
                 m                                             :  integer to store the number of rows
                 n                                             :  integer to store the number of columns
                 Member functions/methods:
                 Composite(int mm, int nn)                     :  to initialise the size of the matrix, m=mm and n=nn
                 int isComposite(int p)                        :  to return 1 if the number is composite otherwise returns 0
                 void fill ()                                  :   to fill the elements of the array with the first (m × n) composite numbers
                                                                 in column wise
                 void display()                                :  to display the array in a matrix form
                 Specify the class Composite giving details of the constructor(int, int), int is Composite(int), void fill() and void display(). Define a main()
                 function to create an object and call all the functions accordingly to enable the task.              [10]





                                                                                                                       673
                                                                                                        Sample Paper   673
   670   671   672   673   674   675   676   677   678   679   680