Computer Mock 2024
Computer Mock 2024
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
The intended marks for questions or parts of questions are given in brackets[].
PART I – 20 MARKS
Answer all questions.
While answering questions in this Part, indicate briefly your working and reasoning,
wherever required.
Question 1
(i) If x=A’BC+AB’C+ABC+A’B’C, then find the value of x, when A=1, B=0 and C=1 [1]
(a) 2
(b) 0
(c) 1
(d) A.B.C
(ii) Assertion: De Morgan’s Law states that (A+B)’ = A’.B’ and (A.B)’=A’+B’
Reason : De Morgan’s theorem explains that the complement of sum of the variables is
same as the product of the complements of the variables and vice versa.
(a) Both Assertion and Reason are true, and Reason is the correct explanation for Assertion.
(b) Both Assertion and Reason are true, but Reason is not the correct explanation for
Assertion.
(c) Assertion is true and Reason is false.
(d) Assertion is false and Reason is true
1
(iv) What will be the output of the following code? [1]
“was it a car or a cat I saw?”.substring(9,12);
(a) was
(b) car
(c) cat
(d) saw
(v) The cardinal form of the expression F(x,y,z) = x’y’z’ + x’y’z + xyz’ is [1]
(a) ∑(0,1,6)
(b) Π(0,1,6)
(c) ∑(0,2,6)
(d) Π(0,1,6)
(vi) Assertion: “this” keyword in Java refers to the current instance of a class. [1]
Reason : It is used to access static members of the class.
(a) Both Assertion and Reason are true, and Reason is the correct explanation for Assertion.
(b) Both Assertion and Reason are true, but Reason is not the correct explanation for
Assertion.
(c) Assertion is true and Reason is false.
(d) Assertion is false and Reason is true
(vii) Name the search logic which at each stage, compares the sought key value with the key value
of the middle element of the array. [1]
(viii) State the different applications of Stack. [1]
(ix) Write any two characteristics of Binary tree. [1]
(x) List any two cases to analyze algorithm complexities. [1]
Question 2
(i) Convert the following infix notation to prefix form. [2]
X+(Y–Z)+((W+E)*F)/J
(ii) Each element of an array P[-12….10, 12…40] requires one byte of storage. If the array is
stored in column major order with the beginning location 1500, determine the location of
P[10][13]. [2]
(iii)With reference to the code given below, answer the questions that follow along with dry
run/working.
boolean num(int x)
{
int a=1;
for(int c=x; c>0;c/=10)
a*=10;
return((x*x%a)==x);
}
(a) What will the function num() return when the value of x = 25? [2]
(b) What is the method num() performing? [1]
2
(iv) The following function is a part of some class. It sorts the array A[ ] in ascending order
using insertion sort technique. There are some places in the code marked by ?1?, ?2? and
?3? which must be replaced by expressions / statements so that the program works correctly.
void insertsort(int A[ ])
{
int m=?1?;
int b,i,t;
for(i=1;i<m;i++)
{
t=A[i];
b=i-1;
while(?2? && t <A[b])
{
A[b+1]=A[b];
?3?
}
A[b]=t;
}
}
(a) What is the expression or statement at ?1? [1]
(b) What is the expression or statement at ?2? [1]
(c) What is the expression or statement at ?3? [1]
PART II – 50 MARKS
Answer six questions in this part, choosing two questions from
Section A, two from Section B and two from Section C.
SECTION - A
Answer any two questions.
Question 3
In Tanayaka Higher Secondary School, the School Board decided that a student should be given a
homework if any of the following conditions are true;
• The student was absent for two tests and got less than 60% marks in test average.
OR
• The student was absent for two tests and did not come to school in proper uniform.
OR
• The student got less than 60% marks in test average and did not take part in nature quiz.
The inputs are:
INPUTS
B The student was absent for 2 tests
M The student got less than 60% marks in test average
Q The student did not take part in nature quiz
U The student did not come to school in proper uniform
(In all the above cases, 1 indicates yes and 0 indicates no.)
Output: H – the student will be given homework [1 indicates yes and 0 indicates no in all cases]
3
(a) Draw the truth table for the inputs and outputs given above and write the SOP expression for
H(B, M, Q, U) [5]
(b) Reduce the above expression H (B, M, Q, U) by using 4-variable Karnaugh map, showing the
various groups (i.e. octal, quads and pairs).Draw the logic gate diagram for the reduced
expression. Assume that the variables and their complements are available as inputs. [5]
Question 4
(b) Draw the logic gate diagram for the reduced expression. Assume that the variables and
their complements are available as inputs. [1]
(ii) From the logic circuit diagram given below, name the outputs (1), (2), (3) and (4) and
finally derive the Boolean expression (Output) and simplify it. Identify the propositional
connective which is equivalent to the simplified Boolean expression. [4]
(iii) Construct a logic circuit using NAND gates only for the expression M.(N+O) [1]
Question 5
(i) How is a Half Adder different from a Full Adder? Draw the truth table, logic diagram and
derive the sum and carry expression for Full Adder. [5]
(ii) Verify if the following proposition is valid by using truth table. [2]
(P→Q).(P→R)=P→(Q.R)
(iii) How is Decoder different from Multiplexer? Also mention the applications of
Multiplexer. [3]
4
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 [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.
For Example: 28
28=22+82=4+64=68
68=62+82=36+64=100
100=12+02+02=1 +0+0=1
Hence, 28 is a happy number.
Example:12
12 =12+22=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 member of the
class are given below:
Classname : Happy
Data members/ instance variables:
n : stores the number
Member functions/ Methods :
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 digit of the number
x using recursive technique
void ishappy() : 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() function to create an object and
call the methods to check for happy number.
5
Question 7 [10]
Specify the class Sum_RowCol giving details of the constructor, the functions void
row_col(int mx, int nx), void readrow_col( ) , void display_mat( ) and void sum_mat( ).
Define the main() function to create an object and call the functions accordingly to enable the
task.
Question 8 [10]
A class Text has been defined to display the sentence in reverse order word wise, For example
Input: God is great
Output: doG si taerg
Class name : Text
Data members/ Instance Variables:
str : to store the original string
nstr : to store the new string
Member Functions/Methods :
Text(… ) : Parameterized constructor to initialize
the data member
String reverse(String) : reverse the sentence word wise.
void display( ) : display the original and new strings
Specify the class Text, giving details of the constructor(…),String reverse (String) and
void display(). Define the main() function to create an object and call the functions
accordingly to enable the task.
6
SECTION – C
Answer any two questions.
Each program should be written in such a way that it clearly depicts the logic of the problem
stepwise.
This can be achieved by using comments in the program and mnemonic names or pseudo codes
for algorithms. The programs must be written in Java and the algorithms must be written in
general/ standard form, wherever required / specified.
(Flow charts are not required.)
Question 9 [5]
A Travel Agency manager decided to implement some auto upgrading applications. The details of
the classes Travel and Journey are given below:
Assume that the super class Travel has been defined. Using the concept of inheritance, specify the
class Journey giving the details of the constructor(...), double fnDiscount( ) and void fnOutput( ).
Main method need not be written.
7
Question 10 [5]
In a computer game, a vertical column and a pile of rings are displayed. The objective of the game is
to pile up rings on the column till it is full. It can hold 10 rings at the most. Once the column is full,
the rings have to be removed from the top, till the column is empty and the game is over. Define the
class GameRing with the following details:
Specify the class GameRing giving the details of the constructor() and functions void jump_in(int),
void jump_out(). Also define the main() functions to create an object and call methods accordingly to
enable the task.
Question 11
(i) What is the worst case complexity for the following code segment? [1]
for(i=0;i<A;i++)
{
Statements
}
for(j=0;j<B;j++)
{
for(k=0;k<C;k++)
{
Statements
}
}
(ii) How would the complexity change if all the three loops went to N instead
of A, B & C? [1]
(iii) Answer the following questions from the diagram of a Binary Tree given below:
(a) Write the In-order traversal of the above tree structure. [1]
(b) Write the successor of the node F [1]
(c) Write the internal nodes of a tree [1]