You are on page 1of 4

Date: 09.09.

2020 Marks: 25
Class: XII Time: 1 hr.
First Term Examination
Computer Science
_____________________________________________________________________________________
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 the questions

Question 1
a) Simplify the following Boolean expression using laws of Boolean Algebra. At each step state clearly
the law used for simplification. XY.(X.Y + Y.Z) [½]
b) State the DeMorgan’s Laws. Verify any one of them using truth table. [½]
c) Find the complement of F(A,B,C,D)= [A + { ( B+C) . (B’+ D’)}] [½]
d) Using the truth table verify PQ+ PQ’ = P ​[½]
e) If X=A’BC + AB’C + ABC + A’BC’ then find the value of X when A=1; B=0; C=1 [½]
Question 2
a) What is constructor overloading? [1]
b) Write any one Difference between if .. else ladder and switch .. case. [1]
c) Difference between public and private. [1]
d) What is a function prototype? [1]
e) What is the significance of void keyword? [1]
Question 3
The following is a method/function of some class. Give the output of the function perform( ) when the
value of ‘n’ is 6579. ​[2½]
void perform (int n)
{
int s=0, g;
while(n>0)
{
if(n%2==1)
n/=10;
g=n%10;
System.out.print(“\n g = \t” + g);
s=s+g;
n/=5;
}
System.out.print(“\n s = \t” + s);
}
Page 1 | 4 pppk-CSc12-09092020
Part II
(Answer all the Three Sections)
One question from each Section

Section - A
(Answer any one of the following questions)
Question 4
a) Obtain the Truth Table to verify the following expression : x (y+z) = x.y + x.z. Also name the law stated
above. [2]
b) Minimise the following expression. At each step state clearly the law used. [3]
Y = (A + B’). (B + CD)’

Question 5.
a) Show that the dual of P’QR’ + PQ’R + P’Q’R is equal to the complement of PQ’R + Q(P’R’ + PR’) [2]
b) Verify if X’YZ+XY’Z+XYZ’+XYZ= XY+YZ+XZ [3]

Section - B
(Answer any one of the following questions)
Question 6 [5]
Design a class PrimePalinGen to generate prime palindrome numbers. [A number is said to be prime
palindrome if the number is a prime as well as a palindrome number.]
Prime number is a number having only two factors i.e. 1 and itself and Palindrome number is a number
which is same as its reverse.
Example: 11 (where 11 is a prime number and a palindrome number)
Some of the members of the class are given below:
Class name​ : PrimePalinGen
Data members/instance variables
start : to store the start of range
end : to store the end of range
Methods/Member functions
PrimePalinGen(int a, int b) : parameterized constructor to initialize the data members
start=a and end=b
int isPrime(int i) : returns 1 if the number is prime otherwise, returns 0
int isPalin(int i) : returns 1 if the number is a palindrome otherwise, returns 0
void generate( ) : generates all prime palindrome numbers between start and end by
invoking the functions isPrime() and isPalin().

Specify the class PrimePalinGen giving details of the constructor( ), int isPrime(int) and int isPalin(int).
You​ need not write main ​method

Page 2 | 4 pppk-CSc12-09092020
Question 7 [5]
A class called EvenSeries has been defined to find the smallest value of integer, n, such that,
2 + 4/2!+8/3!+16/4!+....2n /n! >= S, where 2.0 < S < 7.0.

Some of the members of the class EvenSeries are given below:


Class name : EvenSeries
Data members:
n : long integer type to store number of terms.
S : float variable where 2.0 < S < 7.0.
k : float variable to store the value of series evaluated.
Member functions:
EvenSeries() : constructor to initialize data members to 0.
void accept() : to accept value of data member S.
long fact(long x) : to compute and return factorial of x.
Void disp() : calculates and displays the least value of n.
Specify the class EvenSeries giving details of the constructor and functions void accept(), long fact(long)
and void disp(). The ​main function need not be​ written.

Section - C
(Answer any one of the following questions)
Question 8
A class quad contains the following data members and member functions to find the roots of a
quadratic equation.
Class name : quad
Data members
a, b,c. x1, x2 : float
Member functions
quad(float,float,float) : constructor to assign values to data members.
float discriminant() : to return discriminant [b​2​ -4ac].
void root_equal() : to display the root if both roots are equal.
void imag() : to display the roots, if roots are imaginary.
void root_real() : to display two real, unequal roots.
void root() : to call other appropriate functions to find the solution of the problem.
If ax​ + bx +c =0 is the quadratic equation, then if b​2​ – 4ac >0 – roots are real, unequal
2​

X1 = -b+ √b2 − 4ac /2a


X2 = -b- √b2 − 4ac /2a
If b2 – 4ac =0 -----roots are real, equal. x1=x2=-b/2a
If b​2​-4ac<0 ------ roots are imaginary.

Specify the class quad giving the details of the functions:-

Page 3 | 4 pppk-CSc12-09092020
quad(float , float, float), float discriminant(), void root_real(), void root() You may assume that the other
functions are written for you. You ​need not write main​ function.

Question 9 [5]
Input a word in uppercase and check for the position of the first occurring vowel and perform the
following operation.
i) Words that begin with a vowel are concatenated with “Y” . For example, EUROPE becomes
EUROPEY.
ii) Words that contain a vowel in between should have the first part from the position of the
vowel till end, followed by the part of the string from beginning till position of the vowel and
is concatenated by “C”. For example PROJECT becomes OJECTPRC.
iii) Words which do not contain a vowel are concatenated with “N”. For example, SKY becomes
SKYN.

Design a class Rearrange using the description of the data members and member functions given below:
Class name : Rearrange
Data members
Txt : to store a word
Cxt : to store the rearranged word
len : to store the length of the word
Member functions
Rearrange() : constructor to initialize the instance variables
void readword() : to accept the word input in UPPERCASE
void convert() : converts the word into its changed form and stores it in string Txt
void display() : displays the original and the changed word

Specify the class Rearrange giving the details of void readword(), void convert() and void display().

Page 4 | 4 pppk-CSc12-09092020

You might also like