*Answer all questions in Part I (compulsory) and six questions from Part-II, choosing two questions from Section-A, two from Section-B and two from Section-C.*

*All working, including rough work, should be done on the same sheet as the rest of the answer.*

*The intended marks for questions or parts of questions are given in brackets *[ ].

** **

**PART I**

*Answer all questions*

**Question 1. [1X5=5]**

(a) State the difference between an interface and a class.

(b)Verify using the truth table, if (X=>Y).(Y=>X) is a tautology, contradiction or contingency.

(c) What is an abstract class?

(d) Show how a NAND gate can be used to construct an OR gate.

(e) Define inheritance. How is it useful in programming?

** ****Question 2. [2 x 5=10]**

- State the difference between Function Overloading and Function Overriding.
- Convert the following expression F(X,Y,Z)=XY+Y’Z into minterms.
- Simplify the following expression using law of Boolean algebra. At each step clearly state the law used for simplification. xy+xz+xyz
- State the differences between a constructor and a function.
- For an array of real numbers x [-15….10, 15….40] find the address of x [5,20 ], if x [0] [0] is stored in location 1500 in the column major order. Assume that each element requires 1 bytes.

** **

**Question3. **

The following is a function of some class. What will be the output of the function display( ) when the value of

val is equal to 6?Show the dry run / working. **[5]**

int display (int val)

{

if(val==0)

return 0;

else

returnval+ display(val-1);

}

**Part II**

Answer six questions in this part, choosing two questions from Section A, two from Section B and twofrom Section C.

**Section A**

Answer any two questions

**Question 4.**

a) Given the Boolean function: F (A, B, C, D) = Σ (0, 1, 2, 5, 8, 9, 10)

(i) Reduce the above expression by using 4 – variable K-Map, showing the various groups (i.e.; octal, quads and pairs).

(ii) Draw the Logic gate diagram of the reduced expression. Assume that the variable and their complements are available as inputs. **[1]**

b) Given G(X,Y,Z,W)= π(0,2,4,6,8,9,10,11)

(i) Reduce the above expression by using 4 variable Karnaugh map, showing the various groups (i.e. Octal, quads and pairs). **[4]
**(ii) Draw the logic gate diagram for the reduced expression. Assume that the variables and their complements are available as inputs.

**[1]**

**Question 5**

- Draw a logic diagram for the following function using only NOR gates:
**[3]**

(A, B, C) = (A’ + B’) . (B + C’)

2. Convert the following expression into canonical Sum-Of-Product form: **[3]**

(X, Y, Z) = X’.Y + X’.Y’ + Y.Z’

3. What is a half adder? Draw the truth table, derive its Boolean expression and draw a logic diagram for half adder. **[4]**

**Question 6**

(a) Draw the truth table to prove the following proportional logic expression: A <=> B = (A <=> B) ^ (B => A) [**3] **

(b) State a difference between a Tautology and Contradiction. **[2] **

(c) Draw the truth table and a logic gate diagram of Octal to Binary Encoder. **[5]**

**Section B**

**Answer two questions**

Each program should be written in such a way that it clearly depicts the logic of the problem. This can beachieved by using mnemonic names and comments in the program. (Flowcharts and algorithms are notrequired)

**The programs must be written in Java.**

**Question 7 [10] **

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.

The details of the members of the class are given below:

Class name : Composite

Data members /instance variables :

arr[ ][ ] : stores the composite numbers column wise

m : integer to store the number of rows

n : integer to store the number of columns

Member functions :

Composite(int mm, intnn ) : to initialize the size of the matrix m=mm and n=nn

IntisComposite(int p ) : returns 1 if 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( ) : displays the array in a matrix form.

Specify the class Composite giving details of the constructor Composite (int,int), intisComposite(int), void fill( ) and void display( ).

Define a main( ) function to create an object and call the functions accordingly to enable the task.

** ****Question8.**

In “Piglatin” a word such as KING is replaced by INGKAY, while TROUBLE becomes OUBLETRAY and so on. The first vowel of the original word becomes the start of the translation, any preceding letters being shifted towards the end and followed by AY. Words that begin with a vowel or which do not contain any vowel are left unchanged.

Design a class Piglatin using the description of the data members and member functions given below:

Class name | Piglatin |

variables : | |

Txt | to store a word |

len | to store the length |

Member functions : | |

Piglatin( ) | constructor to initialize the data members |

void readstring( ) | to accept the word input in UPPER CASE |

void convert ( ) | converts the word into its piglatin form and displays the word (changed or unchanged) |

void consonant( ) | Counts and displays the number of Consonants present in the given word. |

Specify the class Piglatin giving the details of the constructor, void readstring( ), void convert( ) and void consonant( ). Also define the main function to create an object and call methods accordingly to enable the task.** [10]**

**Question 9.**

** **A class Hifact has been defined to find the HCF of two numbers using the recursive technique. This HCF is used to find the LCM of two numbers. Some members of the class are given below:-

Class name : Hifact

Data members

a, b ,hcf, lcm : integers

Member functions

Hifact() : constructor to assign initial values to data members

Voidgetdata() : to input values of a and b

void change() : to swap a and b if a> b

intrechcf(int, int) : to find hcf using recursive technique

intfn_lcm(int,int,int) : to find lcm using a,b and hcf

void result() : to invoke rechcf() and fn_lcm() and to print lcm, hcf of the two numbers a and b.

Specify the class Hifact giving details of constructor, void getdata(), void change(), intrechcf() and intfn_lcm(). Write the main function and find the hcf and lcm of any two integers a and b**. [10]**

** ****Section C**

**Answer any two questions**

Each program should be written in such a way that it clearly depicts the logic of the problem step wise.This can also be achieved by using comments in the program and mnemonic names or pseudo codes foralgorithms. The program must be written in Java and the algorithms must be written in general/standard form, wherever required/ specified. (Flowcharts are not required.)

**Question 10 **

A class Student defines the personal data of a student while another class Marks defines to the roll number, name of subject and marks obtained by the student.

The details of classes are as:

**Class name: Student**

Data members/instance variables:

name, sex : string variables to store name and gender male/female

age : integer variable to store age of the student.

Member functions/methods :

Student( ) : constructor to assign initial values to the data members.

void show( ) : to print personal data of student.

**Class Name : Marks **

Data members/instance variables :

rollno, marks : integers to store roll number and marks.

subject : string variable to store name of subject

Member functions/methods :

Marks( ) : constructor to assign initial values to the data members of the child and Base class.

int point() : to return the point obtained according to the following:

Marks Point

>=90 1

70 – 89 2

50 – 69 3

40 – 49 4

< 40 5

void show( ) : to display name, sex, age, roll number, marks, subject and point of the student by invoking suitable function.

Specify the class Student giving the details of the constructor, function void show(). Using the concept of inheritance, specify the class Marks giving the details of the constructor,intpoint() and void show( ) function. You do not need to write the main() function. **[5]**

**Question 11.**

Rack is a kind of data structure which can store utmost 20 books. The Rack restriction is that a book can be kept into the rack or removed only at one end and i.e., on the top. The class Rack has the following details.

**Class name: Rack**

Data members

book[] : an array of string of maximum 50 locations to store books.

limit : stores the capacity of the array

name : String variable to store name of the book.

top: integer to indicate topmost book in the rack.

Member functions

Rack():constructor to store blank in the array book[].

Rack(int m) : constructor to initialize the data members m to limit and -1 to top.

void putthebook() : input name of the book into variable name and adds it on the top into the array[],if possibleelse display the message “overflow”

void removebook() : to remove a book from the top of the rack, if array is empty then display the message “Rack underflow”

void disp() : displays the books present in the list

Specify the class Rack giving details of only the constructor Rack(int), member function void putthebook(int), void removebook().Assume that other functions have been defined.The main function need not be written. **[5]**

**Question 12.**

A magic number is a number in which the eventual sum of digits of the number is equal to 1. For example, 172 = 1 + 7 + 2 = 10 10 = 1 + 0 = 1

Then 172 is a magic number.

Design a class Magic to check if a given number is a magic number. Some of the members of the class are given below:

Class name : Magic

Data members

n : stores the number

Member functions

Magic() : constructor to assign 0 to n

void getnum(intnn) : to assign the parameter value to the number, n=nn

int sum_of_digits(int) : return the sum of the digits of number void ismagic() checks if the given number is a magic number by calling the function sum_of_digits(int) and displays appropriate message. **[5]**