Prashnikaप्रश्निका
Code
About
Computer ScienceSpecimenClass 12

ISC Computer Science 2024 Specimen Paper with Answers

The ISC Computer Science 2024 Specimen Paper for Class 12: all 28 questions, 70 marks in all, in printed order and in full. It is free to download: tap "Show answer" under a question to see its answer, or use the download button to save the questions as a PDF, with or without answers; "Print this paper" below prints it as it was set.

28questions
70marks
10chapters
Q1(i)1 mark · MCQOpen: Absorption law states that:

Choose the correct option.

Absorption law states that:
  • (a)$A \cdot ( A' + B) = A$
  • (b)$A + ( A \cdot B) = A$
  • (c)Both (a) and (b)
  • (d)$A \cdot ( B + C ) = A \cdot B + A \cdot C$
Show answer

Answer

Correct option: (b)

Answer: (b) $A + (A \cdot B) = A$ This is the Absorption Law. Option (a) $A \cdot (A' + B)$ expands (by the Distributive Law) to $A \cdot A' + A \cdot B = 0 + AB = AB$, which is not equal to $A$ in general (e.g. $A=1, B=0$ gives $AB=0 \neq A=1$), so (a), and hence (c), are not valid absorption identities.
Q1(ii)1 mark · Assertion-reasonOpen: A=0 B=1 C=0 and D=1 and minterm is A' · B · C' · D Which one of the following…

Study the Assertion and Reason and choose the correct option.

Assertion: $A=0\quad B=1\quad C=0$ and $D=1$ and minterm is $A' \cdot B \cdot C' \cdot D$

Reason: The final sum term must be $0$ so $A$ and $C$ are complemented.

Which one of the following options is correct?
  • (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.
Show answer

Answer

Correct option: (c)

The Assertion is true: for a minterm, a variable is written uncomplemented if its value is 1 and complemented if its value is 0; here $A=0, B=1, C=0, D=1$ gives exactly $A'BC'D$, which matches the given minterm. The Reason is false: it calls this a 'sum term' that 'must be 0', but that is the rule for forming a MAXTERM (POS) - a minterm is a PRODUCT term that must evaluate to 1, not a sum term equal to 0; so the Reason's stated justification is incorrect even though its numeric conclusion happens to agree. Answer: (c) Assertion is true and Reason is false.
Q1(iii)1 mark · MCQOpen: According to the Principle of duality, the Boolean equation (P + Q') · R · 1 =…

Choose the correct option.

According to the Principle of duality, the Boolean equation $(P + Q') \cdot R \cdot 1 = P \cdot R + Q' \cdot R$ will be equivalent to:
  • (a)$P \cdot Q' + R + 1 = (P + R) \cdot (Q' + R)$
  • (b)$P \cdot Q' + R + 0 = (P + R) \cdot (Q' + R)$
  • (c)$P' \cdot Q + R + 1 = (P' \cdot R') \cdot (Q + R')$
  • (d)$P \cdot Q' + R \cdot 0 = (P + R) \cdot (Q' + R)$
Show answer

Answer

Correct option: (b)

Answer: (b) $P \cdot Q' + R + 0 = (P + R) \cdot (Q' + R)$ By the Principle of Duality, every $\cdot$ is replaced by $+$, every $+$ is replaced by $\cdot$, and every $1$ is replaced by $0$ (variables unchanged). Applying this to $(P+Q') \cdot R \cdot 1 = P \cdot R + Q' \cdot R$ gives $P \cdot Q' + R + 0 = (P + R) \cdot (Q' + R)$, which is option (b).
Q1(iv)1 mark · MCQOpen: The complement of the Boolean expression (X · Y)' + Z' is:

Choose the correct option.

The complement of the Boolean expression $(X \cdot Y)' + Z'$ is:
  • (a)$(X + Y) \cdot Z$
  • (b)$X \cdot Y \cdot Z$
  • (c)$(X' + Y') \cdot Z'$
  • (d)$(X' + Y') \cdot Z$
Show answer

Answer

Correct option: (b)

Answer: (b) $X \cdot Y \cdot Z$ By De Morgan's Law: $[(X \cdot Y)' + Z']' = [(X \cdot Y)']' \cdot [Z']' = (X \cdot Y) \cdot Z = X \cdot Y \cdot Z$.
Q1(v)1 mark · MCQOpen: The equivalent of P ∧ Q ∨ ~ P ∧ ~ Q will be:

Choose the correct option.

The equivalent of $P \land Q \lor \sim P \land \sim Q$ will be:
  • (a)$((P \land Q) \lor \sim P) \land \sim Q$
  • (b)$(P \land Q) \lor (\sim P \land \sim Q)$
  • (c)$P \land (Q \lor \sim P) \land \sim Q$
  • (d)$P \land (Q \lor (\sim P \land \sim Q))$
Show answer

Answer

Correct option: (b)

Answer: (b) $(P \land Q) \lor (\sim P \land \sim Q)$ Since $\land$ (AND) has higher precedence than $\lor$ (OR), $P \land Q \lor \sim P \land \sim Q$ is evaluated as $(P \land Q) \lor (\sim P \land \sim Q)$.
Q1(vi)1 mark · Assertion-reasonOpen: Boolean algebra and Binary number system are different from each other.

Study the Assertion and Reason and choose the correct option.

Assertion: Boolean algebra and Binary number system are different from each other.

Reason: There are some basic operations like AND, OR and NOT which are performed only in Boolean algebra.

  • (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.
Show answer

Answer

Correct option: (a)

Both the Assertion and the Reason are true. Boolean algebra (a system of logic with values 0/1 and operators AND, OR, NOT used to evaluate logical statements) is indeed different from the Binary number system (a positional number system in base 2 used to represent numeric quantities, with arithmetic operators like addition), even though both use only the digits 0 and 1. The Reason correctly explains this: basic logical operations such as AND, OR and NOT are defined and performed only in Boolean algebra, not as standard operations of the binary number system. Answer: (a) Both Assertion and Reason are true, and Reason is the correct explanation for Assertion.
Q1(vii)1 mark · Short answerOpen: What is the relevance of the keyword static for a data member of a class

Answer the following.

What is the relevance of the keyword static for a data member of a class
Show answer

Answer

The keyword static, when used with a data member of a class, makes it a class variable instead of an instance variable: only a single copy of that data member is created and it is shared by all objects of the class (rather than a separate copy for each object). Its value persists across all objects and can be accessed directly using the class name, even without creating an object.
Q1(viii)1 mark · Short answerOpen: State any one purpose of using interfaces in Java programming.

Answer the following.

State any one purpose of using interfaces in Java programming.
Show answer

Answer

One purpose of using interfaces in Java is to achieve multiple inheritance of type: since a Java class can extend only one class, it can implement more than one interface to inherit (and be forced to provide implementations for) the abstract behaviour/method signatures declared in each of them.
Q1(ix)1 mark · Short answerOpen: Define Canonical form of an expression with respect to its Cardinal form.

Answer the following.

Define Canonical form of an expression with respect to its Cardinal form.
Show answer

Answer

The Canonical form of a Boolean expression is its complete standard form - canonical SOP (sum of minterms) or canonical POS (product of maxterms) - in which every term contains all the variables of the function, each appearing either in true or complemented form. The Cardinal form is simply the compact shorthand way of writing this canonical form: it lists only the decimal numbers of the minterms/maxterms using the symbol $\Sigma$ (for sum of minterms) or $\Pi$ (for product of maxterms), e.g. $F(A,B,C)=\Sigma m(1,3,7)$ is the Cardinal form of the canonical SOP $A'B'C + A'BC + ABC$.
Q1(x)1 mark · Short answerOpen: State any one application each of half adder and full adder.

Answer the following.

State any one application each of half adder and full adder.
Show answer

Answer

Half adder: used where only two bits (with no carry-in) need to be added, e.g. for adding the least significant bits of two binary numbers. Full adder: used to add three bits at a time (two operand bits plus a carry-in from a previous stage), so full adders are cascaded to build a multi-bit parallel binary adder / arithmetic circuit that correctly propagates the carry.
Q2(i)2 marks · ConversionOpen: Convert the following infix notation to postfix form. ( A / B + C ) / ( D * ( E…

Convert the following.

Convert the following infix notation to postfix form. ( A / B + C ) / ( D * ( E − F )
Show answer

Answer

The printed expression is missing a closing bracket; taking the evidently intended, balanced expression $(A/B+C)/(D*(E-F))$ and converting using operator precedence and left-to-right scanning with a stack: $(A/B+C) \to A\ B\ /\ C\ +$ $(E-F) \to E\ F\ -$ $(D*(E-F)) \to D\ E\ F\ -\ *$ Combining the two parts with the outer $/$: Postfix: $A\ B\ /\ C\ +\ D\ E\ F\ -\ *\ /$
Q2(ii)2 marks · NumericalOpen: An array ARR[-4 … 6, -2 … 12], stores elements in Row Major Wise, with the…

Solve the following.

An array $ARR[-4 \dots 6, -2 \dots 12]$, stores elements in Row Major Wise, with the address $ARR[2][3]$ as 4142. If each element requires 2 bytes of storage, find the Base address.
Show answer

Answer

Rows $= 6-(-4)+1 = 11$, columns $M = 12-(-2)+1 = 15$, $W = 2$ Row Major: $Address(ARR[i][j]) = Base + W \times [(i-L_r) \times M + (j-L_c)]$ $4142 = Base + 2 \times [(2-(-4)) \times 15 + (3-(-2))]$ $4142 = Base + 2 \times [90+5] = Base + 190$ $Base = 4142 - 190 = 3952$

Final answer: 3952

Q2(iii)3 marks · Case basedOpen: The following functions are a part of some class: void Try(char ch[],int x) {…

Answer the following questions on the given code.

The following functions are a part of some class:
void Try(char ch[],int x)
{   System.out.println(ch); char temp;
    if ( x<ch.length/2)
        {   temp=ch[x];
            ch[x]= ch[ch.length-x-1];
            ch[ch.length-x-1] = temp;
            Try(ch,x+1);
        }   }
void Try1(String n)
{   char c[]=new char[n.length()];
    for(int i=0;i<c.length;i++)
        c[i] = n.charAt(i);
    Try(c,0);
}
(a)[2]
What will the output of Try( ) when the value of ch[]={‘P’, ‘L’,‘A’, ‘Y’} and x=1?
(b)[1]
What will the output of Try1( ) when the value of n=”SKY”?
Show answer

Answer (a)

Output: PLAY PALY (Verified by running the code.) Try(ch,1) first prints the array as given: PLAY. Since $x(1) < ch.length/2 (=2)$, it swaps ch[1] and ch[4-1-1]=ch[2], i.e. swaps 'L' and 'A', giving PALY, then calls Try(ch,2). This call prints the array again: PALY. Now $x(2)$ is not $< 2$, so the if-block is skipped and the recursion stops.

Answer (b)

Output: SKY YKS Try1("SKY") copies the string into a char array and calls Try(c,0), which first prints SKY. Since $0 < 3/2 (=1)$, it swaps c[0] and c[3-0-1]=c[2], i.e. 'S' and 'Y', giving YKS, then calls Try(c,1), which prints YKS. Now $x(1)$ is not $<1$, so the recursion stops.
Q2(iv)3 marks · Case basedOpen: The following function is a part of some class which computes and returns the…

Fill in the blanks marked ?1?, ?2? ... so that the code works.

The following function is a part of some class which computes and returns the value of a number ‘p’ raised to the power ‘q’ ($p^q$). There are some places in the code marked by ?1? , ?2? , ?3? which must be replaced by an expression / a statement so that the function works correctly.
double power ( double p , int q )
{   double r = ?1? ;
    int c = ( q<0 ) ? -q : q ;
    if ( q == 0)
        return  1 ;
    else
    {   for (int i = 1; i <= c ;?2?, i++);
        return (q>0)? r : ?3?;
    }
}
(a)[1]
What is the expression or statement at ?1?
(b)[1]
What is the expression or statement at ?2?
(c)[1]
What is the expression or statement at ?3?
Show answer

Answer (a)

Blanks: 1

?1? = 1

Answer (b)

Blanks: r = r * p

?2? = r = r * p

Answer (c)

Blanks: 1 / r

?3? = 1 / r
Q310 marks · Case basedOpen: A Football Association coach analyses the criteria for a win/draw of his team…

Answer the following using a truth table and a Karnaugh map.

A Football Association coach analyses the criteria for a win/draw of his team depending on the following conditions. • If the Centre and Forward players perform well but Defenders do not perform well. OR • If Goalkeeper and Defenders perform well but the Centre players do not perform well. OR • If all perform well. The inputs are:
INPUTS
CCentre players perform well
DDefenders perform well
FForward players perform well
GGoalkeeper perform well
(In all the above cases, 1 indicates yes and 0 indicates no.) Output: X - Denotes the win/draw criteria [1 indicates win/draw and 0 indicates defeat in all cases]
(i)[5]
Draw the truth table for the inputs and outputs given above and write the SOP expression for $X(C, D, F, G)$.
(ii)(a)[2.5]
Reduce the above expression $X (C, D, F, G)$ by using 4-variable Karnaugh map, showing the various groups (i.e. octal, quads and pairs).
(ii)(b)[2.5]
Draw the logic gate diagram for the reduced expression. Assume that the variables and their complements are available as inputs.

Draw: logic gate diagram for the reduced expression

Show answer

Answer

3(i): Truth table for $X(C,D,F,G)$:
CDFGX
00000
00010
00100
00110
01000
01011
01100
01111
10000
10010
10101
10111
11000
11010
11100
11111
From the three given conditions: Condition 1 (Centre, Forward well; Defenders not well): $C \cdot D' \cdot F$ Condition 2 (Goalkeeper, Defenders well; Centre not well): $C' \cdot D \cdot G$ Condition 3 (all perform well): $C \cdot D \cdot F \cdot G$ SOP expression: $X(C,D,F,G) = C \cdot D' \cdot F + C' \cdot D \cdot G + C \cdot D \cdot F \cdot G$ 3(ii): Plotting the minterms of $X = CD'F + C'DG + CDFG$, i.e. $\Sigma(5,7,10,11,15)$, on a 4-variable K-map (rows CD: 00,01,11,10; columns FG: 00,01,11,10) gives three pairs (no quad or octet is possible for this function): Pair (10,11): $C=1,D=0,F=1$, G varies $\Rightarrow CD'F$ Pair (5,7): $C=0,D=1,G=1$, F varies $\Rightarrow C'DG$ Pair (7,15): $D=1,F=1,G=1$, C varies $\Rightarrow DFG$ Reduced (minimal) SOP: $X(C,D,F,G) = CD'F + C'DG + DFG$ Logic gate diagram: three 3-input AND gates feeding one 3-input OR gate.
Q4(i)5 marks · Case basedOpen: F(A,B,C,D) = π (0, 1, 2, 3, 4, 6, 9, 11, 13) Reduce the Boolean function…

Reduce the following using a Karnaugh map.

$F(A,B,C,D) = \pi (0, 1, 2, 3, 4, 6, 9, 11, 13)$
(a)[4]
Reduce the Boolean function $F(A,B,C,D) = \pi (0, 1, 2, 3, 4, 6, 9, 11, 13)$ by using 4-variable Karnaugh map, showing the various groups (i.e. octal, quads and pairs).
(b)[1]
Draw the logic gate diagram for the reduced expression. Assume that the variables and their complements are available as inputs.

Draw: logic gate diagram for the reduced expression

Show answer

Answer (a)

Groups: (9, 13) → (A' + C + D'); (0, 2, 4, 6) → (A + D); (1, 3, 9, 11) → (B + D')

Reduced expression: F = (A' + C + D').(A + D).(B + D')

Maxterms (0s) grouped: quad (0, 2, 4, 6) gives (A + D), quad (1, 3, 9, 11) gives (B + D'), pair (9, 13) gives (A' + C + D').

Answer (b)

Logic gate diagram for $F(A,B,C,D) = (A+D) \cdot (B+D') \cdot (A'+C+D')$: three OR gates feeding one AND gate.
Diagram for this answer
Q4(ii)(a)4 marks · DerivationOpen: From the logic circuit diagram given below, name the outputs (1), (2) and (3)…

Answer the following.

From the logic circuit diagram given below, name the outputs (1), (2) and (3) and finally derive the Boolean expression (F) and simplify it. Identify the propositional connective which is equivalent to the simplified Boolean expression.
Figure for this question
Show answer

Answer

Outputs: (1) = X+Y', (2) = X.Z, (3) = (X+Y').(X.Z). Simplifying, F(X,Y,Z) = (3) + Z' = X + Z', which is logically equivalent to the propositional connective IMPLICATION, $Z \Rightarrow X$.
  1. (1) = X + Y' - output of the top OR gate, combining input X with Y' (from the NOT gate on Y).
  2. (2) = X . Z - output of the AND gate, combining input X (same branch that feeds gate (1)) with input Z.
  3. (3) = (1).(2) = (X+Y').(X.Z) - output of the middle AND gate, combining outputs (1) and (2).
  4. By the Distributive Law: (X+Y').(X.Z) = X.Z.X + X.Z.Y' = X.Z + X.Y'.Z (using the Idempotent Law X.X=X).
  5. X.Z + X.Y'.Z = X.Z.(1+Y') = X.Z (by the Distributive Law and the Identity Law 1+Y'=1); equivalently, by the Absorption Law X.(X+Y')=X, so (3) = X.Z directly.
  6. F = (3) + Z' - output of the final OR gate, combining (3) with Z' (from the bottom NOT gate on Z): F = X.Z + Z'.
  7. By the identity A + A'.B = A + B (with A=Z', B=X): Z' + Z.X = Z' + X.
  8. Therefore F(X,Y,Z) = X + Z'.
  9. X + Z' is equivalent to the propositional connective Implication, Z => X, since P=>Q is equivalent to (~P v Q); here Z=>X is equivalent to Z'+X = X+Z'.
Q4(ii)(b)1 mark · NumericalOpen: If A=1 and B=0 then find the value of (A' + 1) · B

Answer the following.

If $A=1$ and $B=0$ then find the value of $(A' + 1) \cdot B$
Show answer

Answer

$(A'+1) \cdot B$ for $A=1, B=0$: $A'=0$, so $A'+1 = 0+1 = 1$ (Identity Law: anything OR 1 = 1). Then $1 \cdot B = 1 \cdot 0 = 0$.

Final answer: 0

Q5(i)5 marks · DrawingOpen: Draw the logic circuit to encode the following Hexadecimal number (1, 3, 5, 6…

Draw the following.

Draw the logic circuit to encode the following Hexadecimal number (1, 3, 5, 6, 9, A, C, E) to its binary equivalents. Also state the binary equivalents of the given numbers.

Draw: logic circuit to encode the hexadecimal numbers 1, 3, 5, 6, 9, A, C, E to their binary equivalents

Show answer

Answer

Binary equivalents: $1=0001,\ 3=0011,\ 5=0101,\ 6=0110,\ 9=1001,\ A=1010,\ C=1100,\ E=1110$. This is an 8-line to 4-line ENCODER: each hex digit has its own input line (I1, I3, I5, I6, I9, I10, I12, I14), active (=1) when that value is selected. Four OR gates combine these input lines to produce the 4-bit binary output B3 B2 B1 B0 (B3 = MSB): $B_3 = I_9+I_{10}+I_{12}+I_{14}$ $B_2 = I_5+I_6+I_{12}+I_{14}$ $B_1 = I_3+I_6+I_{10}+I_{14}$ $B_0 = I_1+I_3+I_5+I_9$
Diagram for this answer
Q5(ii)3 marks · Truth tableOpen: Verify if the following proposition is valid using the truth table:

Answer the following using a truth table.

Verify if the following proposition is valid using the truth table:
Show answer

Answer

ABCB.CA => B.CA => BB => C(A => B).(B => C)A => B.C <=> (A => B).(B => C)
000011111
001011111
010011000
011111111
100000101
101000101
110001001
111111111
The last column is not 1 in every row (row A=0, B=1, C=0 gives 0), so the proposition is not valid.
Q5(iii)2 marks · Short answerOpen: How is a 2 to 4 decoder related to 4:1 multiplexer?

Answer the following.

How is a 2 to 4 decoder related to 4:1 multiplexer?
Show answer

Answer

A 2-to-4 decoder has 2 input (select) lines and 4 output lines; for every combination of the 2 inputs exactly one of the 4 outputs becomes 1 (it generates each of the 4 minterms of the 2 input variables). A 4:1 multiplexer has 4 data-input lines, 2 select lines and a single output; the same 2 select lines choose which one of the 4 data inputs is passed to the output. So a 2-to-4 decoder is essentially the selecting/enabling core of a 4:1 MUX: if each decoder output line is ANDed with the corresponding data input, and the four AND outputs are ORed together, the result is exactly a 4:1 multiplexer - both circuits use the same 2 select lines to distinguish among the same 4 possibilities.
Q610 marks · ProgramOpen: An Evil Number is a number which contains even number of 1’s in its binary…

Write the program described below.

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: 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 initialize the data member with legal initial value void acceptNum( ) : to accept a positive integer number void rec_bin (int x) : to convert the decimal number into its binary equivalent using recursive technique void check( ) : 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.
Show answer

Answer

import java.util.Scanner;

class Evil
{
    int num;
    String bin;

    Evil()
    {
        num = 0;
        bin = "";
    }

    void acceptNum()
    {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a positive integer: ");
        num = sc.nextInt();
    }

    void rec_bin(int x)
    {
        if (x > 0)
        {
            rec_bin(x / 2);
            bin = bin + (x % 2);
        }
    }

    void check()
    {
        rec_bin(num);
        int count = 0;
        for (int i = 0; i < bin.length(); i++)
        {
            if (bin.charAt(i) == '1')
                count++;
        }
        if (count % 2 == 0)
            System.out.println(num + " is an Evil Number.");
        else
            System.out.println(num + " is not an Evil Number.");
    }

    public static void main(String args[])
    {
        Evil obj = new Evil();
        obj.acceptNum();
        obj.check();
    }
}
Explanation: rec_bin(x) recursively divides x by 2, and after the recursive call returns (i.e. once x becomes 0), it appends each remainder (x%2) to the string bin on the way back up the call stack, which builds the binary equivalent in the correct (MSB to LSB) order. check() calls rec_bin(num), counts the number of '1' characters in bin, and reports the number as Evil if that count is even. Tested (run for real): for num=10, rec_bin builds bin="1010" (two 1's, even), and the program correctly printed "10 is an Evil Number."
Q710 marks · ProgramOpen: A class Composite contains a two-dimensional array of order [m x n]. The…

Write the program described below.

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 initialize 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 isComposite(int), void fill( ) and void display( ). Define a main( ) function to create an object and call all the functions accordingly to enable the task.
Show answer

Answer

class Composite
{
    int arr[][];
    int m, n;

    Composite(int mm, int nn)
    {
        m = mm;
        n = nn;
        arr = new int[m][n];
    }

    int isComposite(int p)
    {
        if (p < 4)
            return 0;
        int count = 0;
        for (int i = 1; i <= p; i++)
            if (p % i == 0)
                count++;
        return (count > 2) ? 1 : 0;
    }

    void fill()
    {
        int num = 3;
        for (int j = 0; j < n; j++)
        {
            for (int i = 0; i < m; i++)
            {
                num++;
                while (isComposite(num) == 0)
                    num++;
                arr[i][j] = num;
            }
        }
    }

    void display()
    {
        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < n; j++)
                System.out.print(arr[i][j] + "\t");
            System.out.println();
        }
    }

    public static void main(String args[])
    {
        Composite obj = new Composite(3, 3);
        obj.fill();
        obj.display();
    }
}
Explanation: isComposite(p) counts all factors of p from 1 to p; a count greater than 2 means p is composite. fill() searches upward from 4 for successive composite numbers and stores them column by column (outer loop over columns j, inner loop over rows i), so the array is filled with the first m*n composite numbers in column-major order. Tested (run for real) with m=n=3: the first 9 composite numbers 4,6,8,9,10,12,14,15,16 were placed column-wise, and display() printed: 4 9 14 6 10 15 8 12 16
Q810 marks · ProgramOpen: A class Encode has been defined to replace only the vowels in a word by the…

Write the program described below.

A class Encode has been defined to replace only the vowels in a word by the next corresponding vowel and form a new word. i.e. A → E, E → I, I → O, O → U, U → A and a → e, e → i, i → o, o → u, and u → a Example: Input: Institution Output: Onstotatoun Some of the members of the class are given below: Class name : Encode Data members/instance variables: word : to store a word length : integer to store the length of the word new_word : to store the encoded word Methods / Member functions: Encode( ) : default constructor to initialize data members with legal initial values void acceptWord( ) : to accept a word void nextVowel( ) : to replace only the vowels from the word stored in ‘word’ by the next corresponding vowel and to assign it to ‘newword’, with the remaining alphabets unchanged void display( ) : to display the original word along with the encrypted word Specify the class Encode giving details of the constructor( ), void acceptWord( ), void nextVowel( ) and void display( ). Define a main ( ) function to create an object and call the functions accordingly to enable the task.
Show answer

Answer

import java.util.Scanner;

class Encode
{
    String word, new_word;
    int length;

    Encode()
    {
        word = "";
        new_word = "";
        length = 0;
    }

    void acceptWord()
    {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter a word: ");
        word = sc.nextLine();
        length = word.length();
    }

    void nextVowel()
    {
        for (int i = 0; i < length; i++)
        {
            char ch = word.charAt(i);
            switch (ch)
            {
                case 'A': new_word += 'E'; break;
                case 'E': new_word += 'I'; break;
                case 'I': new_word += 'O'; break;
                case 'O': new_word += 'U'; break;
                case 'U': new_word += 'A'; break;
                case 'a': new_word += 'e'; break;
                case 'e': new_word += 'i'; break;
                case 'i': new_word += 'o'; break;
                case 'o': new_word += 'u'; break;
                case 'u': new_word += 'a'; break;
                default: new_word += ch;
            }
        }
    }

    void display()
    {
        System.out.println("Original word : " + word);
        System.out.println("Encoded word  : " + new_word);
    }

    public static void main(String args[])
    {
        Encode obj = new Encode();
        obj.acceptWord();
        obj.nextVowel();
        obj.display();
    }
}
Explanation: nextVowel() scans each character of word; if it is one of the 10 vowels (upper- or lower-case), it is replaced by the next vowel in the cycle A->E->I->O->U->A (and a->e->i->o->u->a) using a switch statement, while all other (consonant) characters are copied unchanged into new_word. Tested (run for real): for word="Institution", the program correctly produced new_word="Onstotatoun", matching the example given in the question.
Q95 marks · Case basedOpen: Shelf is a kind of data structure which can store elements with the restriction…

Answer the following on the class described.

Shelf is a kind of data structure which can store elements with the restriction that an element can be added from the rear end and removed from the front end only. The details of the class Shelf are given below: Class name : Shelf Data members/instance variables: ele[ ] : array to hold decimal numbers lim : maximum limit of the shelf front : to point the index of the front end rear : to point the index of the rear end Methods / Member functions: Shelf(int n ) : constructor to initialize lim=n, front= 0 and rear=0 void pushVal(double v) : to push decimal numbers in the shelf at the rear end if possible, otherwise display the message “ SHELF IS FULL ” double popVal( ) : to remove and return the decimal number from the front end of the shelf if any, else returns −999.99 void display( ) : to display the elements of the shelf
(i)[4]
Specify the class Shelf giving details of the functions void pushVal(double) and double popVal( ). Assume that the other functions have been defined. The main( ) function and algorithm need NOT be written.
(ii)[1]
Name the entity described above and state its principle.
Show answer

Answer (i)

void pushVal(double v)
{
    if (rear == lim)
        System.out.println("SHELF IS FULL");
    else
    {
        ele[rear] = v;
        rear++;
    }
}

double popVal()
{
    if (front == rear)
        return -999.99;
    else
    {
        double v = ele[front];
        front++;
        return v;
    }
}
Explanation: pushVal() checks whether rear has reached the limit lim (shelf full) before inserting v at the rear index and advancing rear. popVal() checks whether the shelf is empty (front==rear), returning -999.99 in that case; otherwise it returns the element at front and advances front. Tested (run for real) with lim=3: pushing 1.5, 2.5, 3.5 succeeded, a fourth pushVal correctly printed "SHELF IS FULL", and popVal() correctly returned 1.5 then 2.5 in that order, leaving 3.5 in the shelf.

Answer (ii)

The entity described is a Queue (Linear Queue). It works on the principle of FIFO (First In First Out) - the element inserted first (at the rear) is the element removed first (from the front).
Q105 marks · ProgramOpen: A super class Circle has been defined to calculate the area of a circle. Define…

Write the program described below.

A super class Circle has been defined to calculate the area of a circle. Define a subclass Volume to calculate the volume of a cylinder. The details of the members of both the classes are given below: Class name : Circle Data members/instance variables: radius : to store the radius in decimals area : to store the area of a circle Methods / Member functions: Circle( ... ) : parameterized constructor to assign values to the data members void cal_area() : calculates the area of a circle ($\pi r^2$) void display( ) : to display the area of the circle Class name : Volume Data members/instance variables: height : to store the height of the cylinder in decimals volume : to store the volume of the cylinder in decimals Methods / Member functions: Volume( ... ) : parameterized constructor to assign values to the data members of both the classes double calculate( ) : to calculate and return the volume of the cylinder using the formula ($\pi r^2 h$) where, r is the radius and h is the height void display( ) : to display the area of a circle and volume of a cylinder Assume that the super class Circle has been defined. Using the concept of inheritance, specify the class Volume giving the details of the constructor(...), double calculate( ) and void display( ). The super class, main function and algorithm need NOT be written.
Show answer

Answer

class Volume extends Circle
{
    double height, volume;

    Volume(double r, double h)
    {
        super(r);
        height = h;
    }

    double calculate()
    {
        cal_area();
        volume = area * height;
        return volume;
    }

    void display()
    {
        super.display();
        System.out.println("Volume of Cylinder = " + volume);
    }
}
Explanation: The parameterised constructor Volume(r,h) passes the radius up to the superclass Circle's constructor using super(r), and stores height in the subclass. calculate() invokes the inherited cal_area() (which computes and stores area = pi * radius^2 in the superclass), then multiplies this area by height to get the volume of the cylinder (pi * r^2 * h), storing it in volume and returning it. display() calls super.display() to reuse the superclass's printing of the area, then prints the volume, demonstrating inheritance (reusing radius/area/cal_area from Circle) and method overriding of display(). Tested (run for real) with a stub Circle class matching the given specification: for radius=3, height=5, the program correctly computed area = 28.274... and volume = 141.371...
Q11(i)2 marks · Short answerOpen: With the help of an example, briefly explain the constant factor in time…

Answer the following.

With the help of an example, briefly explain the constant factor in time complexity.
Show answer

Answer

In time complexity analysis, the constant factor is a multiplicative coefficient in a term that does not depend on the input size n. Big-O notation ignores constant factors because, as n becomes very large, they do not change the growth rate (order) of the algorithm - only the relative rate at which the running time grows with n matters. Example: An algorithm that performs $5n$ operations and another that performs $3n$ operations for an input of size n are both $O(n)$ - the constants 5 and 3 (the constant factors) are dropped, since both algorithms still grow linearly with n.
Q11(ii)3 marks · Case basedOpen: Answer the following questions from the diagram of a Binary Tree given below…

Answer the following questions from the binary tree.

Answer the following questions from the diagram of a Binary Tree given below:
(a)[1]
Name the external nodes of the right sub tree.
(b)[1]
State the size and depth of the tree.
(c)[1]
Write the post-order traversal of the above tree structure.
Show answer

Answer (a)

The right subtree of the tree is rooted at F and contains the nodes F, G, E, H. Its external (leaf) nodes are E and H (F has child G, and G has children E and H, so only E and H have no children).

Answer (b)

Size of the tree (total number of nodes) = 7 (nodes A, B, D, F, G, E, H). Depth of the tree (number of edges on the longest root-to-leaf path) = 3 (e.g. A -> F -> G -> E, or A -> F -> G -> H).

Answer (c)

Post-order traversal (Left, Right, Root) of the tree: D B E H G F A

About this specimen paper

The ISC Computer Science 2024 Specimen Paper is a specimen paper for Class 12: 28 questions in printed order, 70 marks in all, asked from 10 chapters. A specimen paper is the sample question paper CISCE publishes before the exam to show the layout and style of that year’s paper. It is a good guide to the pattern you will meet.

The layout of the current Computer Science paper (sections, marks, choices) is in the paper pattern guide.

By kind of question

KindQuestionsMarks printed*
Program435
Case based629
Short answer68
Drawing15
MCQ44
Derivation14
Numerical23
Truth table13
Assertion-reason22
Conversion12

By chapter

ChapterQuestionsMarks printed*
Boolean Algebra1230
Objects330
Data structures310
Computer Hardware38
Inheritance, Interfaces and Polymorphism26
Implementation of algorithms to solve problems13
Recursion13
Arrays, Strings12
Complexity and Big O notation12
Methods11

* Marks are those printed on each question; where a question offers an either-or choice, both options are counted, so the totals can come to more than the paper’s own total.

Common questions

How many questions are in the ISC Computer Science 2024 Specimen Paper?

28 questions, 70 marks in all, shown in full and in printed order on this page.

Which chapters does the ISC Computer Science 2024 Specimen Paper ask most about?

By number of questions: Boolean Algebra (12), Objects (3), Data structures (3) and Computer Hardware (3).

Does this page have the answers to the ISC Computer Science 2024 Specimen Paper?

Tap “Show answer” under a question to see its answer. The download button saves the paper as a PDF, with or without the answers.