ISC Computer Science Question Paper 2012 Solved for Class 12

ISC Computer Science Previous Year Question Paper 2012 Solved for Class 12

Maximum Marks: 70
Time allowed: 3 hours

Part – I
Answer all questions

While answering questions in this Part, indicate briefly your working and reasoning, wherever required.

Question 1.
(a) Using a truth table, verify the following expression: [2]
X + (Y + Z) = (X + Y) + Z
Also, state the law.
(b) Given, F (X, Y, Z) = (X’ + Y’) . (Y + Z’) [2]
Write the function in the canonical product of sum form.
(c) Draw the truth table and logic circuit for a 2-input XNOR gate. [2]
(d) Find the complement of the following expression: [2]
X’ + XY’
(e) If (X ⇒ Y) then write its: [2]
(i) Converse
(ii) Contra positive
Answer:
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 1
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 2

Question 2.
(a) Differentiate between the keywords extends and implements. [2]
(b) State how a binary tree is a recursive data structure. [2]
(c) A matrix B[10][7] is stored in the memory with each element requiring 2 bytes of storage. If the base address at B [x] [1] is 1012 and the address at B |7][3] is 1060, determine the value of ‘x’ where the matrix is stored in Column Major wise. [2]
(d) Convert the following infix notation to its postfix form: [2]
A + (B + C) + (D + E) * F)/G
(e) What is a constructor? State one difference between a constructor and any other member function of a class. [2]
Answer:
(a)

ExtendsImplements
1. Extends keyword is used to implement the concept of inheritance.

2. Extends is used when creating a sub-class.

1. Implements keyword is used for implementing an interface by a class.

2. Implements are used when implementing an interface.

(b) A tree is a recursive data structure because each node has a reference to its other subtrees. e.g. the following binary tree:
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 3
has two binary trees as its children, which are:
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 4
This property of the binary tree is applicable at all levels of binary trees.

(c) Given
i = 10, j = 7, w = 2, B = 1012
r = 10, w = ?
Add [i][j] = 1060
Colomn wise
Add [i][i] = B + [(J – Lc) + (I – Lr)]
⇒ 1060 = 1012 + [(3 – 1) * 10 + (7 – x)] * 2
⇒ 1060 – 1012 = 2 [(7 – x) + 20]
⇒ 48 = 2[(7 – x) + 20]
⇒ 7 – x = 4
⇒ x = 7 – 4 = 3

(d) A + (B + C) + (D + E)*F)/G
= A + (BC + + DE + * F)/G
= A + (BC + + DE + F*)/G
= A + BC + DE + F* + /G
= A + BC + DE + F* + G/
= ABC + DE + F* + G/+

(e) Constructor is a member function used to create and initialise the object with legal set of values. Constructors have same name as that of class while functions have different names.

Question 3.
(a) The following function is a part of some class which computes and sorts an array arr [] is ascending order using the bubble sort technique. There are some places in the code marked by ?1?, ?2?, ?3?, ?4?, ?5? which must be replaced by a statement/expression so that the function works properly:

void bubblesort (int arr [])
{
int i. j, k temp;
for (i = 0; ?1?; i ++)
{
for (j = 0; ?2?;j++)
{
arr[j] > ?3?)
{
temp = arr [j];
?4? = arr [j + 1];
arr [j + 1] = ?5?;
}
}
}
}

(i) What is the expression or statement at ?1? [1]
(ii) What is the expression or statement at ?2? [1]
(iii) What is the expression or statement at ?3? [1]
(iv) What is the expression or statement at ?4? [1]
(v) What is the expression or statement at ?5? [1]
(b) The following function witty() is a part of some class. What will be the output of the function witty( ) when the value of n is ‘SCIENCE’ and the value of p is 5. Show the dry run/working: [5]

void witty (String n, int p)
{
if (p < 0)
System.out.println(" ");
else
{
System. out .printing. char At (p) + " . ");
witty (n, p - 1);
System.out.print[n. char At (p)]:
}
}

Answer:
(a) (i) i < arr.length
(ii) j < arr.length – 1 – i
(iii) arr [j + 1]
(iv) arr [j]
(v) temp
(b) C.
N.
E.
I.
C.
S.
SCIENCE.

Part – II

Answer seven questions in this part, choosing three questions from Section A, two from Section B and tiro from Section C.

Section – A
Answer any three questions

Question 4.
(a) Given the Boolean function:
F(A, B, C, D) = Σ (4, 6, 7, 10, 11, 12, 14, 15).
(i) Reduce the above expression by using 4-variable K-Map. showing the various groups (i.e., octal, quads and pairs). [4]
(ii) Draw the logic gate diagram of the reduced expression. Assume that the variables and their complements are available as inputs. [1]
(b) Given the Boolean function:
F (P, Q, R, S) = Π (0, 5, 7, 8, 10, 12, 13, 14, 15)
(i) Reduce the above expression by using 4-variable K-Map, showing the various groups (i.e., octal, quads and pairs). [4]
(ii) Draw the logic gate diagram of the reduced expression. Assume that the variables and their complements are available as inputs. [1]
Answer:
(a) F(A, B, C, D) = Σ (4, 6, 7, 10, 11, 12, 14, 15).
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 5
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 6
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 7

Question 5.
(a) The Principal of a school intends to select students for admission to class XI on the following criteria:
The student is of the same school and has passed the class X Board Examination with more than 60% marks.
Or
Students are of the same school, has passed the class X Board Examination with less than 60% marks but has taken an active part in co-curricular activities.
Or
The student is not from the same school but has either passed the class X Board Examination with more than 60% marks or has participated in sports at the National Level.
The inputs are:

Inputs
SStudent of the same school.
PHas passed the class X Board Examination with more than 60% marks.
CHas taken an active part in co-curricular activities.
THas participated in sports at the National Level.

(b) Output: X-Denotes admission status [1 indicates granted and 0 indicates refused in all the cases.]
(a) Draw the truth table for the inputs and outputs given above and write the SOP expression. [5]
(b) Reduce X (S, P, C, T) using Karnaugh’s Map.
Draw the logic gate diagram for the reduced SOP expression for X (S, P, C, T) using AND and OR gate. You may use gates with two or more inputs. Assume that the variable and their complements are available as inputs. [5]
Answer:
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 8
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 9
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 10

Question 6.
(a) Verify algebraically if, [3]
X’Y’Z’ + X’Y’Z + X’YZ + X’YZ’ + XY’Z’ + XY’Z = X’ + Y’
(b) Represent the Boolean expression X + YZ’ with the help of NOR gates only. [3]
(c) Define the terms Contingency, Contradiction and Tautology. [4]
(d) Consider the following truth table where A and B are two inputs and X is the output:
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 11
(i) Name and draw the logic gate for the given truth table.
(ii) Write the POS of X (A, B).
Answer:
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 12
(c) Contingency: The proposition that has some combination of 0’s and 1’s in their truth table column are called contingency.
Contradiction: The propositions having only O’S m their truth table column are called contradictions.
Tautology: The propositions having the only 1’s in their truth table column are called tautologies.
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 13

Question 7.
(a) Define Multiplexer and state one of its uses. Draw the logic diagram for a 4 : 1 Multiplexer. [4]
(b) State how a Half Adder is different from a Full Adder. Also, give their respective uses. [3]
(c) Minimize the following expression using Boolean laws: [3]
Q.(Q’ + P)R.(Q + R)
Also, draw the logic gate for the reduced expression.
Answer:
(a) A multiplexer is a combinational circuit that selects binary information from more than one input lines and directs it to a single output line.
It is used in parallel to serial conversion.
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 14
(b) Half Adder is used to add two bits while Full Adder is used to add three bits. Adders are used in ALU to process binary number.
ISC Computer Science Question Paper 2012 Solved for Class 12 image - 15

Section – B
Answer any tivo 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 8.
A class Combine contains an array of integers which combines two arrays into a single array including the duplicate elements, if any, and sorts the combined array. Some of the members of the class are given below: [10]
Class name: Combine
Data Members/instance variables:
com[]: integer array
size: size of the array
Member functions/methods:
Combine(nt nn): parameterized constructor to assign size = nn
void inputarray(): accepts the array elements.
void sort(): sorts the elements of the combined array in ascending order using the selection sort technique.
void mix(Combine A, Combine B): combines the parameterized object arrays and stores the result in the current object array along with duplicate elements, if any.
void display(): displays the array elements
Specify the class Combine giving details of the constructor (int), void inputarray(), void sort(), void mix (Combine, Combine) and void display (). Also, define the main() function to create an object and call the methods accordingly to enable the task.
Answer:

Import java. io.*;
class Combine
{
int com [], size;
public Combine (int nn)
{
size = nn;
com = new int [size];
}
void inputarray () throws IOException
{
Buffered Reader br = new
Buffered Reader [new Input Stream Reader (System.in)];
int i;
for (i = 0; i < size; i++)
{
System.out.println ("Enter a no.");
com [i] = Integer.parseInt[br.readLine ()];
}
}
void sort ()
{
int i, j, t;
for (i = 0; z < size; i++)
{
for (j = i + 1; j < size; j++) { if (com[i] > com [j])
{
t = com [i];
com [i] = com [j];
com [j] = t;
}
}
}
}
void mix (Combine A, Combine B)
{
int i, j;
for (i = 0, j = 0; i < A.size; i ++, j++)
{
com[j] = A.com[i];
{
for (i = 0; i < B.size; i++, j++)
{
com [j] = B.com [i];
}
}
void display ()
{
int i;
for (i = 0; i < size; i ++)
{
System.out.println(com[i]);
}
}
public static void main (String args [ ]) throws IOException
{
Combine c1 = new Combine(5);
Combine c2 = new Combine(3);
Combine c3 = new Combine(8);
c1.inputarray();
c2.inputarray();
c3.mix (c1, c2);
c3.sort();
c3.display();
}
}

Question 9.
Design a class VowelWord to accept a sentence and calculate the frequency of words that begin with a vowel. The words in the input string are separated by a single blank space and terminated by a full stop. The description of the class is given below: [10]
Class name: VowelWord
Data Members/instance variables:
str: to store a sentence
freq: store the frequency of the words beginning with a vowel.
Member functions:
VowelWord(): constructor to initialize data members to a legal initial value
void readstr(): to accept a sentence
void freq_vowel: counts the frequency of the words that begin with a vowel
void display(): to display the original string and the frequency of the words that begin with a vowel.
Specify the class VowelWord giving details of the constructor (), void readstr (), void freq_vowel () and void display (). Also, define the main () function to create an object and call the methods accordingly to enable the task.
Answer:

import java.io.*;
class VowelWord
{
String str;
int freq;
public VowelWord()
{
str = "Evergreen Publications, Jalandhar, Punjab";
freq = 0;
}
void readstr( )throws IOException
{
BufferedReader br = new
BufferedReader (new InputStreamReader (System.in));
System.out.println('Enter a Sentence.');
str = br.readLine ();
}
void freq vowel()
{
String w;
int i , l;
char ch;
l = str.length();
for (i = 0; i< 1; i++)
{ 
w = " "; 
while(str.charAt (i) ! = '' && 
str.chartAt(i)! =' ') 
{ 
w = w + str.charAt (i); 
i++; 
} 
w = w.toLowerCase(); 
ch = w.charAt(0);
if (ch == 'a' || ch == 'e' || ch = 'i' || ch = 'o' || ch = 'u') 
{ 
freq++; 
} 
} 
} 
void display()
 { 
System.out.println("Original String : " + str); 
System.out.println("Frequency of Words Beginning with vowel are : " + freq); 
} 
public static void main(String args[])throws IOException 
{ 
VowelWord ob = new VowelWord(); 
ob.readstr(); ob.ffeq _vowel(); 
ob.display( );
} 
}

Question 10.
A happy number is a number in which the eventual sum of the square of the digits of the number is equal to 1. [10]
Example:
28 = (2)2 + (8)2 = 4 + 64 = 68
68 = (6)2 + (8)2 = 36 + 64 = 100
100 = (1)2 + (0)2 + (0)2 = 1 + 0 + 0 = 1
Hence, 28 is a happy number.
Example:
12 = (1)2 + (2)2 = 1 + 4 = 5
Hence, 12 is not a happy number.
Design a class Happy to check if a given number is a happy number. Some of the members of the class are given below:
Class name: Happy
Data Members/instance variables:
n: stores the number Member functions
Happy( ): constructor to assign 0 to n.
void getnum (int nn): to assign the parameter value to the number n = nn.
int sum_sq_digits (int x): returns the sum of the square of the digits of the number x, using the recursive technique
void is happy (): checks if the given number is a happy number by calling the function sum_sq_digits(int) and displays an appropriate message.
Specify the class Happy giving details of the constructor (), void getnum (int), int sum_sq_digits (int) and void ishappy (). Also define a main ( s) function to create an object and call the methods to check for happy number.
Answer:

class Happy 
{ 
int n, s, d;
public Happy() 
{ 
n = 0; 
} 
void getnum (int nn) 
{ 
n = nn, 
} 
int sum_sq_digits(int x)
{ if (x > 0)
{
d = x%10;
s = s + d*d;
x = x/10;
return (sum_sq_digits (x));
}
else
{
returns;
}
}
void ishappy ()
{
int a;
while (n > 9)
{
s = 0;
n = sum_sq_digits(n):
}
if (n== 1)
System.out.println("Happy No.");
else
System out.println("Not a Happy No.");
}
}

Section – C
Answer any two questions

  • Each Program Algorithm should be written in such a way that it clearly depicts the logic of the problem stepwise.
  • This can also be achieved by using pseudo-codes.
  • Flowcharts are not required
  • The programs must be written in Java.
  • The algorithm must be written in general/standard form, wherever required.

Question 11.
Link is an entity which can hold a maximum of 100 integers. Link enables the user to add elements from the rear end and remove integers from the front end of the entity. Define a class Link with the following details:
Class name: Link
Data Members/instance variables:
Ink []: entity to hold the integer elements,
max: stores the maximum capacity of the entity,
begin: to point to the index of the front end.
end: to point to the index of the rear end.
Member functions:
Link(intmm): constructor to initialize max = mm. begin = 0. end = 0.
void addlink (int v): to add an element from the rear index if possible otherwise display the message “OUT OF SIZE… ”
int dellink(): to remove and return an element from the front index. if possible otherwise display the message “EMPTY …” and return – 99.
void display(): displays the elements of the entity.
(a) Specify the class Link giving details of the constructor (int), void addlink (int), int dellink() and void display ( ). [9]
THE MAIN FUNCTION AND ALGORITHM NEED NOT BE WRITTEN.
(b) What type of data structure is the above entity? [1]
Answer:

(a) class Link
{
int Ink [ ] = new int [100];
int begin, end. max;
public Link (int mm)
{
max = mm;
begin = end = 0;
}
void addlink(int v)
{
if (end==0)
{
end = begin = 1;
Ink [end] = v;
}
else if (end == max)
{
System.out.println("List is Full");
}
else
Ink [++end] = v;
}
}
int dellink ()
{
int a;
if (begin == 0)
{
System.out.println(" Empty...");
return - 99;
}
else if (begin == end)
{
a = Ink [begin];
begin = end = 0;
return a;
}
else
{
a = Ink [begin];
begin++;
return (a);
}
}
void display()
{
int i;
for(i = begin; i < = end; i++) 
{ 
System.out.println(lnk[i]); 
} 
} 
}

(b) It is a Queue.

Question 12.
A superclass Detail has been defined to store the details of a customer. Define a subclass Bill to compute the monthly telephone charge of the customer as per the chart is given below:
Number of calls: Rate
1 – 100: Only rental charge
101 – 200: 60 paise per call + rental charge
201 – 300: 80 paise per call + rental charge
Above 300: 1 rupee per call + rental charge
The details of both the classes are given below:
Class name: Detail
Data members/instance variables:
name: to store the name of the customer
address: to store the address of the customer
telno: to store the phone number of the customer
rent: to store the monthly rental charge
Member functions:
Detail (…): parameterized constructor to assign values to data members
void show (): to display the details of the customer
Class name: Bill
Data members/instance variables:
n: to store the number of calls
amt: to store the amount to be paid by the customer
Member functions:
Bill (…): parameterized constructor to assign values to data members of both classes and to initialize amt = 0.0
void cal(): calculate the monthly telephone charge as per the chart is given above
void show(): displays the details of the customer and amount to be paid.
Specify the class Detail giving details of the constructor, and void show(). Using the concept of inheritance, specify the class Bill giving details of the constructor(), void cal() and void show().
THE MAIN ( ) FUNCTION AND ALGORITHM NEED NOT BE WRITTEN.
Answer:

class Detail
{
protected String name, add;
protected long telno;
protected double rent;
public Detail (String n, String a, long t, double r)
{
name = n;
add = a;
telno = t;
rent = r;
}
void show ()
{
System.out.println(name + " " + add + " " + telno + " " + rent);
}
}
class Bill extends Detail
{
int n;
double amt;
public Bill (String nm, string ad, long tn, double rn, int, n1)
{
super (nm, ad, tn, rn):
n = n1;
amt = 0.0;
}
void cal ()
{
if (n > = 1 && n < = 100)
{
amt = rent;
}
else if (n > 100 && n < = 200)
{ amt = rent + (n - 100) * 0.60;
}
else if (n > 200 && n< = 300)
{
amt = rent + 100 * 0.60 + (n - 200) * 0.80:
}
else if (n > 300)
{
amt = rent + (0.60 * 100) + (0.80 * 100) + (n - 300) * 100);
}
void show()
{
super.show();
System.out.println("Amount to be paid = "+amt/100 + "Rs");
}
}

ISC Class 12 Computer Science Previous Year Question Papers