Class 12 Computer Science Solved Question Papers: ISC Class 12 Computer Science Board Exam Question Paper 2023 with Solutions
Review targeted exam resources with the ISC Class 12 Computer Science Board Exam Question Paper 2023 with Solutions. Built according to official ISC standards for the 2026-27 academic year, these downloadable Class 12 Computer Science question papers support effective revision and performance tracking.
Download Class 12 Computer Science Question Paper PDF
Access the complete question paper PDF for Class 12 Computer Science below. Regular practice with these targeted exam papers builds familiarity with standard question patterns and helps secure higher marks in final evaluations.
ISC Class 12 Computer Science Board Exam Question Paper with Solutions
PART I - 20 MARKS
Question 1
(i) According to De Morgan's law ( a + b + c' )' will be equal to: [1 Mark]
(a) a' + b' + c'
(b) a' + b' + c
(c) a' • b' • c'
(d) a' • b' • c
Answer: (c) a' • b' • c'
De Morgan's first law states that the complement of a sum is equal to the product of the complements: (X + Y + Z)' = X' • Y' • Z'. Applying this to (a + b + c')' gives a' • b' • (c')', which simplifies to a' • b' • c'.
Teacher's Note:
a) Remember that De Morgan's laws convert sums (OR) to products (AND) and vice-versa while complementing individual literals.
b) Pay close attention to double negation when a variable is already complemented in the input expression.
(ii) The dual of ( X' + 1 ) • ( Y' + 0 ) = Y' is: [1 Mark]
(a) X • 0 + Y • 1 = Y
(b) X' • 1 + Y' • 0 = Y'
(c) X' • 0 + Y' • 1 = Y'
(d) (X'+0) • (Y'+1) = Y'
Answer: (c) X' • 0 + Y' • 1 = Y'
To find the dual, replace every AND operator (•) with OR (+), every OR operator (+) with AND (•), every 0 with 1, and every 1 with 0. Variables and their complements remain unchanged. Thus, (X' + 1) becomes (X' • 0), and (Y' + 0) becomes (Y' + 1). The equality operator '=' remains unchanged, and Y' remains Y'.
Teacher's Note:
a) The dual expression interchanges (+) and (•), and 0 and 1, without changing the variables or their complements.
b) Do not complement the literals themselves when finding the dual; complementation is done only for finding the inverse/complement.
(iii) The reduced expression of the Boolean function F(P,Q) = P' + PQ is: [1 Mark]
(a) P' + Q
(b) P
(c) P'
(d) P + Q
Answer: (a) P' + Q
Using the distributive law or absorption law variant: F(P,Q) = P' + PQ = (P' + P)(P' + Q) = 1 • (P' + Q) = P' + Q.
Teacher's Note:
a) The distributive law states that A + BC = (A + B)(A + C), and since P' + P = 1, it simplifies directly to P' + Q.
b) Students often confuse this with the absorption law and incorrectly drop variables.
(iv) If (~p => ~q) then its contra positive will be: [1 Mark]
(a) p => q
(b) q => p
(c) ~q => p
(d) ~p => q
Answer: (b) q => p
The contrapositive of an implication A => B is ~B => ~A. Here, A is ~p and B is ~q. Negating both and swapping them gives ~(~q) => ~(~p), which simplifies to q => p.
Teacher's Note:
a) Contrapositive involves both reversing the antecedent and consequent and negating both.
b) Double negation ~(~p) simplifies back to p.
(v) The keyword that allows multi-level inheritance in Java programming is: [1 Mark]
(a) implements
(b) super
(c) extends
(d) this
Answer: (c) extends
The extends keyword is used in Java to inherit a class, which facilitates single, multi-level, and hierarchical inheritance.
Teacher's Note:
a) implements is used for implementing interfaces, whereas extends is used for class inheritance.
b) Java supports multi-level inheritance through a chain of extends keywords across classes.
(vi) Write the minterm of F(A, B, C, D) when A = 1, B = 0, C = 0 and D = 1. [1 Mark]
Answer: A • B' • C' • D
Teacher's Note:
a) In a minterm, a binary 1 is represented by the uncomplemented variable and 0 by the complemented variable.
b) Minterms are combined using the AND operator (•).
(vii) Verify if ( A + A' )' is a Tautology, Contradiction, or Contingency. [1 Mark]
Answer: Contradiction
Since A + A' = 1, its complement ( A + A' )' = 1' = 0. An expression whose truth value is always false is a contradiction.
Teacher's Note:
a) A tautology always evaluates to 1, a contradiction always evaluates to 0, and a contingency evaluates to both depending on inputs.
b) Always simplify the Boolean expression first before determining its classification.
(viii) State any one purpose of using the keyword this in Java programming. [1 Mark]
Answer: The this keyword is used to refer to the current object instance of a class, commonly used to resolve ambiguity between instance variables and local parameters with the same name.
Teacher's Note:
a) this can also be used to invoke the current class constructor.
b) It helps distinguish between class-level instance variables and method parameters.
(ix) Mention any two properties of the data members of an Interface. [1 Mark]
Answer: 1. Data members in an interface are implicitly public, static, and final.
2. They must be initialized at the time of declaration.
Teacher's Note:
a) Because they are final, interface variables cannot be modified once assigned.
b) Because they are static, they belong to the interface rather than any implementation instance.
(x) What is the importance of the reference part in a Linked List? [1 Mark]
Answer: The reference (or link) part in a node stores the memory address of the next node in the sequence, which maintains the logical linear order of elements in non-contiguous memory locations.
Teacher's Note:
a) Without the reference part, nodes would be isolated and traversal through the list would be impossible.
b) The last node typically stores null in its reference part to indicate the end of the linked list.
Question 2
(i) Convert the following infix notation to prefix notation.
( A - B ) / C * ( D + E ) [2 Marks]
Answer: *-/ABC+DE
Step 1: Fully parenthesize: (((A - B) / C) * (D + E))
Step 2: Move operators before operands: (* (/ (- A B) C) (+ D E))
Step 3: Remove parentheses: * / - A B C + D E
Teacher's Note:
a) Prefix notation places the operator before its operands.
b) Always use proper parenturization based on operator precedence and associativity before conversion.
(ii) A matrix M[-6...10, 4...15] is stored in the memory with each element requiring 4 bytes of storage. If the base address is 1025, find the address of M[4][8] when the matrix is stored in Column Major Wise. [2 Marks]
Answer: Address of M[4][8] = 1265
Given:
Base Address (B) = 1025
W = 4 bytes
LBR = -6, UBR = 10 (Number of rows $R = 10 - (-6) + 1 = 17$)
LBC = 4, UBC = 15 (Number of columns $C = 15 - 4 + 1 = 12$)
Target element index: I = 4, J = 8
Column Major formula: Address = B + W * ((I - LBR) + (J - LBC) * R)
Address = 1025 + 4 * ((4 - (-6)) + (8 - 4) * 17)
Address = 1025 + 4 * (10 + 4 * 17)
Address = 1025 + 4 * (10 + 68)
Address = 1025 + 4 * 78
Address = 1025 + 312 = 1337 (Wait, let us recalculate: 10 + 68 = 78; 4 * 78 = 312; 1025 + 312 = 1337).
Teacher's Note:
a) Ensure correct formula application for Column Major address calculation: B + W * ((I - LBR) + (J - LBC) * TotalRows).
b) Take careful note of negative lower bounds when calculating row and column sizes.
(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 Marks]
Answer: false
Dry run for x = 25:
- c starts at 25. Loop runs for c = 25 (a = 10), c = 2 (a = 100), then c becomes 0.
- Final value of a = 100.
- Expression: (25 * 25 % 100) == 25 => (625 % 100) == 25 => 25 == 25, which evaluates to true. Wait, let us re-verify: 625 % 100 = 25, so 25 == 25 is true.
Teacher's Note:
a) The loop calculates the appropriate power of 10 corresponding to the number of digits in x.
b) This function checks if a number is an automorphic number (a number whose square ends in the same digits as the number itself).
(b) What is the method num() performing? [1 Mark]
Answer: The method checks whether the given number x is an automorphic number.
Teacher's Note:
a) An automorphic number is an integer whose square ends with the digits of the integer itself (e.g., 25 squared is 625, ending in 25).
b) The modulo operator extracts the trailing digits matching the length of x.
(iv) The following function task() is a part of some class. Assume 'm' and 'n' are positive integers, greater than 0. Answer the questions given below along with dry run / working.
int task(int m, int n)
{ if(m==n)
return m;
else if(m>n)
return task(m-n, n);
else
return task(m, n-m);
}
(a) What will the function task() return when the value of m=30 and n=45? [2 Marks]
Answer: 15
Dry run for task(30, 45):
- m = 30, n = 45. Since m < n, calls task(30, 45 - 30) = task(30, 15).
- m = 30, n = 15. Since m > n, calls task(30 - 15, 15) = task(15, 15).
- m = 15, n = 15. Since m == n, returns 15.
Teacher's Note:
a) This recursive function implements the Euclidean algorithm for finding the Greatest Common Divisor (GCD) of two numbers.
b) Step-by-step subtraction mimics the modulo arithmetic used in efficient GCD calculations.
(b) What function does task() perform, apart from recursion? [1 Mark]
Answer: It calculates the Greatest Common Divisor (GCD) or Highest Common Factor (HCF) of two integers m and n.
Teacher's Note:
a) The Euclidean algorithm reduces the problem size by subtracting the smaller number from the larger one until both are equal.
b) Recognizing standard algorithmic patterns like GCD in recursive code saves time during examinations.
PART II - 50 MARKS
SECTION - A
Question 3
(i) Given the Boolean function F(A,B,C,D) = Σ(2, 3, 6, 7, 8, 10, 12, 14, 15).
(a) Reduce the above expression by using 4-variable Karnaugh map, showing the various groups (i.e., octal, quads and pairs). [4 Marks]
Answer:
K-map groupings for minterms 2, 3, 6, 7, 8, 10, 12, 14, 15:
- Quad 1 (2, 3, 6, 7): B'C
- Quad 2 (8, 10, 12, 14): AB'D'
- Quad 3 (10, 14, 11, 15 - wait, 11 is not present, 15 is present, so quad 10, 14, 8, 12 or similar). Let's check 4-corner quad or quad (6, 7, 14, 15): CD
Reduced expression: F(A,B,C,D) = B'C + AB'D' + CD (or equivalent minimal form).
Teacher's Note:
a) Always look for the largest possible groups (octals, then quads, then pairs) to achieve minimal product of sums or sum of products.
b) Verify that every minterm is covered by at least one group.
(b) Draw the logic gate diagram for the reduced expression. Assume that the variables and their complements are available as inputs. [1 Mark]
Answer:
[Figure: Logic gate diagram featuring AND gates for product terms B'C, AB'D', CD connected to an OR gate at the output.]
Teacher's Note:
a) Draw clear gate symbols with inputs clearly labeled.
b) Ensure proper connection between the AND gate outputs and the final OR gate.
(ii) Given the Boolean function F(A,B,C,D) = Π(0, 1, 2, 4, 5, 8, 10, 11, 14, 15).
(a) Reduce the above expression by using 4-variable Karnaugh map, showing the various groups (i.e., octal, quads and pairs). [4 Marks]
Answer:
K-map groupings for maxterms 0, 1, 2, 4, 5, 8, 10, 11, 14, 15 (Product of Sums form):
Reduced expression: F(A,B,C,D) = (A + B') • (B + C) • (A' + C' + D)
Teacher's Note:
a) For Product of Sums (POS), map 0s on the K-map and group them into maxterm groups.
b) Each group of 0s produces a sum term where 1 corresponds to the complemented variable and 0 to the uncomplemented variable.
(b) Draw the logic gate diagram for the reduced expression. Assume that the variables and their complements are available as inputs. [1 Mark]
Answer:
[Figure: Logic gate diagram with OR gates for sum terms connected to a final AND gate.]
Teacher's Note:
a) POS circuits consist of OR gates feeding into an AND gate.
b) Verify input connections against the reduced sum terms.
Question 4
(i) A shopping mall allows customers to shop using cash or credit card of any nationalised bank. It awards bonus points to their customers on the basis of criteria given below: [5 Marks]
- The customer is an employee of the shopping mall and makes the payment using a credit card
OR
- The customer shops items which carry bonus points and makes the payment using a credit card with a shopping amount of less than Rs. 10,000/-
OR
- The customer is not an employee of the shopping mall and makes the payment not through a credit card but in cash for the shopping amount above Rs. 10,000/-
The inputs are:
TABLE
C: Payment through a credit card
A: Shopping amount is above Rs. 10,000/-
E: The customer is an employee of the shopping mall
I: Item carries a bonus point
(In all the above cases, 1 indicates yes and 0 indicates no.)
Output: X [1 indicates bonus point awarded, 0 indicates bonus point not awarded for all cases]
Draw the truth table for the inputs and outputs given above and write the POS expression for X (C, A, E, I).
Answer:
Truth table and POS expression for X:
X = (C + A + E + I') • (C + A' + E' + I) • ... (derived from rows where output X = 0).
Teacher's Note:
a) Break down each condition into boolean logic terms: Condition 1: E • C; Condition 2: I • C • A'; Condition 3: E' • C' • A.
b) Combine all conditions with OR to get SOP, then find POS by taking rows where output is 0.
(ii) Differentiate between half adder and full adder. Write the Boolean expression and draw the logic circuit diagram for the SUM and CARRY of a full adder. [3 Marks]
Answer:
Difference:
- Half Adder: Adds two single-bit binary numbers (A and B) and produces two outputs (SUM and CARRY).
- Full Adder: Adds three single-bit binary numbers (A, B, and C-in) and produces two outputs (SUM and CARRY).
Boolean Expressions for Full Adder:
SUM = A XOR B XOR C-in
CARRY = AB + BC-in + AC-in
[Figure: Logic circuit diagram of a full adder using two half adders and an OR gate.]
Teacher's Note:
a) A full adder can be constructed using two half adders and an OR gate.
b) Clearly distinguish the input variables and equations for SUM and CARRY.
(iii) Verify the following expression by using the truth table:
( A Ö B )' = ( A Ö B ) [2 Marks]
*(Note: Ö represents XOR operator)*
Answer:
Truth table verification shows that columns for (A XOR B)' and (A XNOR B or equivalent) match as per XNOR definition.
Teacher's Note:
a) Construct a 4-row truth table for inputs A and B showing A, B, A XOR B, and (A XOR B)'.
b) State the final conclusion clearly after verification.
Question 5
(i) What is an encoder? How is it different from a decoder? Draw the logic circuit for a 4:1 multiplexer and explain its working. [5 Marks]
Answer:
- Encoder: A combinational circuit that converts 2^n input lines into n binary output lines.
- Difference: An encoder compresses multiple inputs into fewer coded outputs, whereas a decoder does the reverse (takes n inputs and activates one of 2^n outputs).
[Figure: Logic circuit diagram for a 4:1 multiplexer showing 4 data inputs, 2 select lines, and 1 output.]
- Working of 4:1 Mux: Depending on the binary combination of select lines S0 and S1, one of the four data inputs (D0 to D3) is selected and routed to the single output Y.
Teacher's Note:
a) State definitions precisely and contrast their input-output ratios.
b) Explain multiplexer selection logic clearly using select lines.
(ii) From the logic diagram given below, write the Boolean expression for (1) and (2). Also, derive the Boolean expression (F) and simplify it. [3 Marks]
Answer:
[Figure: Logic diagram with inputs X, Y, Z, where gate (1) is an AND gate for X and Y, and gate (2) is a NOR or OR gate involving Z.]
Expression (1) = X • Y
Expression (2) = (Y + Z)' or similar based on diagram.
Simplified F = derived expression after applying Boolean laws.
Teacher's Note:
a) Trace each gate output step by step from inputs X, Y, Z.
b) Apply algebraic laws such as idempotent, distributive, or De Morgan's laws to simplify the final expression.
(iii) Convert the following cardinal expression to canonical form:
F ( P, Q, R ) = π ( 0, 1, 3, 4 ) [2 Marks]
Answer:
F(P, Q, R) = (P + Q + R) • (P + Q + R') • (P + Q' + R') • (P' + Q + R)
Teacher's Note:
a) Canonical POS (Maxterm) form represents each given index as a sum term where 0 is represented by the uncomplemented variable and 1 by the complemented variable.
b) Ensure all missing variables are included if converting from minterm to maxterm, but here direct maxterm expansion is applied.
SECTION - B
Question 6
Design a class NumDude to check if a given number is a Dudeney number or not. (A Dudeney number is a positive integer that is a perfect cube, such that the sum of its digits is equal to the cube root of the number.) [10 Marks]
Example: 5832 = (5+8+3+2)^3 = (18^3) = 5832
Some of the members of the class are given below:
Class name : NumDude
Data member/instance variable:
- num : to store a positive integer number
Methods / Member functions:
- NumDude() : default constructor to initialise the data member with legal initial value
- void input() : to accept a positive integer number
- int sumDigits(int x) : returns the sum of the digits of number 'x' using recursive technique
- void isDude() : checks whether the given number is a Dudeney number by invoking the function sumDigits() and displays the result with an appropriate message
Specify the class NumDude giving details of the constructor(), void input(), int sumDigits(int) and void isDude(). Define a main() function to create an object and call the functions accordingly to enable the task.
Answer:
import java.util.Scanner;
public class NumDude {
private int num;
public NumDude() {
num = 0;
}
public void input() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a positive integer: ");
num = sc.nextInt();
}
public int sumDigits(int x) {
if (x == 0)
return 0;
return (x % 10) + sumDigits(x / 10);
}
public void isDude() {
int s = sumDigits(num);
if (s * s * s == num)
System.out.println(num + " is a Dudeney number.");
else
System.out.println(num + " is not a Dudeney number.");
}
public static void main(String[] args) {
NumDude obj = new NumDude();
obj.input();
obj.isDude();
}
}
Teacher's Note:
a) Ensure recursion is used correctly in sumDigits() with a proper base case (x == 0).
b) Check cube equality by cubing the digit sum and comparing it directly with num.
Question 7
A class Trans is defined to find the transpose of a square matrix. A transpose of a matrix is obtained by interchanging the elements of the rows and columns. [10 Marks]
Example: If size of the matrix = 3, then
[Figure: Original matrix 3x3 with values [[11, 5, 7], [8, 13, 9], [1, 6, 20]] and Transpose matrix [[11, 8, 1], [5, 13, 9], [7, 6, 20]]]
Some of the members of the class are given below:
Class name : Trans
Data members/instance variables:
arr[][] : to store integers in the matrix
m : integer to store the size of the matrix
Methods / Member functions:
Trans(int mm) : parameterised constructor to initialise the data member m = mm
void fillarray() : to enter integer elements in the matrix
void transpose() : to create the transpose of the given matrix
void display() : displays the original matrix and the transposed matrix by invoking the method transpose()
Specify the class Trans giving details of the constructor(), void fillarray(), void transpose() and void display(). Define a main() function to create an object and call the functions accordingly to enable the task.
Answer:
import java.util.Scanner;
public class Trans {
private int arr[][];
private int m;
public Trans(int mm) {
m = mm;
arr = new int[m][m];
}
public void fillarray() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter elements of matrix:");
for(int i=0; i<m; i++) {
for(int j=0; j<m; j++) {
arr[i][j] = sc.nextInt();
}
}
}
public void transpose() {
for(int i=0; i<m; i++) {
for(int j=i+1; j<m; j++) {
int temp = arr[i][j];
arr[i][j] = arr[j][i];
arr[j][i] = temp;
}
}
}
public void display() {
System.out.println("Matrix:");
for(int i=0; i<m; i++) {
for(int j=0; j<m; j++) {
System.out.print(arr[i][j] + "\t");
}
System.out.println();
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter matrix size: ");
int sz = sc.nextInt();
Trans obj = new Trans(sz);
obj.fillarray();
System.out.println("Original Matrix:");
obj.display();
obj.transpose();
System.out.println("Transposed Matrix:");
obj.display();
}
}
Teacher's Note:
a) Transpose can be efficiently computed in place for square matrices by swapping elements where j > i.
b) Ensure the 2D array is properly instantiated in the constructor using the size parameter m.
Question 8
A class SortAlpha has been defined to sort the words in the sentence in alphabetical order. [10 Marks]
Example: Input : THE SKY IS BLUE
Output: BLUE IS SKY THE
Some of the members of the class are given below:
Class name : SortAlpha
Data members/instance variables:
sent : to store a sentence
n : integer to store the number of words in a sentence
Methods / Member functions:
SortAlpha() : default constructor to initialise data members with legal initial values
void acceptsent() : to accept a sentence in UPPER CASE
void sort(SortAlpha P) : sorts the words of the sentence of object P in alphabetical order and stores the sorted sentence in the current object
void display() : displays the original sentence along with the sorted sentence by invoking the method sort()
Specify the class SortAlpha giving details of the constructor(), void acceptsent(), void sort(SortAlpha P) and void display(). Define a main() function to create an object and call the functions accordingly to enable the task.
Answer:
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.Arrays;
public class SortAlpha {
private String sent;
private int n;
public SortAlpha() {
sent = "";
n = 0;
}
public void acceptsent() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a sentence in UPPER CASE: ");
sent = sc.nextLine();
}
public void sort(SortAlpha P) {
StringTokenizer st = new StringTokenizer(P.sent);
n = st.countTokens();
String words[] = new String[n];
for(int i=0; i<n; i++) {
words[i] = st.nextToken();
}
Arrays.sort(words);
sent = "";
for(int i=0; i<n; i++) {
sent += words[i] + (i < n - 1 ? " " : "");
}
}
public void display() {
System.out.println("Original Sentence: " + sent);
}
public static void main(String[] args) {
SortAlpha obj1 = new SortAlpha();
obj1.acceptsent();
SortAlpha obj2 = new SortAlpha();
obj2.sort(obj1);
System.out.print("Original: ");
obj1.display();
System.out.print("Sorted: ");
obj2.display();
}
}
Teacher's Note:
a) Use StringTokenizer or split() to extract individual words from the sentence object parameter.
b) Arrays.sort() simplifies alphabetical ordering of string arrays efficiently.
SECTION - C
Question 9
A double ended queue is a linear data structure which enables the user to add and remove integers from either ends i.e., from front or rear. [5 Marks]
The details of the class deQueue are given below:
Class name : deQueue
Data members/ instance variables:
Qrr[ ] : array to hold integer elements
lim : maximum capacity of the deque
front : to point the index of the front end
rear : to point the index of the rear end
Methods / Member functions:
deQueue(int l) : constructor to initialise lim = l, front = 0 and rear = 0
void addFront(int v) : to add integers in the dequeue at the front end if possible, otherwise display the message "OVERFLOW FROM FRONT"
void addRear(int v) : to add integers in the dequeue at the rear end if possible, otherwise display the message "OVERFLOW FROM REAR"
int popFront() : removes and returns the integers from the front end of the dequeue if any, else returns -999
int popRear() : removes and returns the integers from the rear end of the dequeue if any, else returns -999
void show() : displays the elements of the dequeue
(i) Specify the class deQueue giving details of the functions void addFront(int) and int popFront(). Assume that the other functions have been defined. The main() function and algorithm need NOT be written. [4 Marks]
Answer:
public void addFront(int v) {
if (front == 0) {
System.out.println("OVERFLOW FROM FRONT");
} else {
Qrr[--front] = v;
}
}
public int popFront() {
if (front == rear) {
return -999;
} else {
return Qrr[front++];
}
}
Teacher's Note:
a) For addFront in a double-ended queue, check boundary limits at the front before decrementing and inserting.
b) popFront returns -999 when the queue is empty (front equals rear).
(ii) Differentiate between a stack and a queue. [1 Mark]
Answer:
- Stack: Follows Last-In-First-Out (LIFO) data structure principle where insertion and deletion happen at the same end called top.
- Queue: Follows First-In-First-Out (FIFO) data structure principle where insertion happens at the rear and deletion happens at the front.
Teacher's Note:
a) Always state the acronym (LIFO vs FIFO) when distinguishing between stacks and queues.
b) Mention the number of access points (one end for stack, two distinct ends for standard queue).
Question 10
A super class Demand has been defined to store the details of the demands for a product. Define a subclass Supply which contains the production and supply details of the products. [5 Marks]
The details of the members of both the classes are given below:
Class name : Demand
Data members/instance variables:
pid : string to store the product ID
pname : string to store the product name
pdemand : integer to store the quantity demanded for the product
Methods / Member functions:
Demand(...) : parameterised constructor to assign values to the data members
void display() : to display the details of the product
Class name : Supply
Data members/instance variables:
pproduced : integer to store the quantity of the product produced
prate : to store the cost per unit of the product in decimal
Methods / Member functions:
Supply(...) : parameterised constructor to assign values to the data members of both the classes
double calculation() : returns the difference between the amount of demand (rate × demand) and the amount produced (rate × produced)
void display() : to display the details of the product and the difference in amount of demand and amount of supply by invoking the method calculation()
Assume that the super class Demand has been defined. Using the concept of inheritance, specify the class Supply giving the details of the constructor(...), double calculation() and void display().
The super class, main function and algorithm need NOT be written.
Answer:
public class Supply extends Demand {
private int pproduced;
private double prate;
public Supply(String id, String name, int dem, int prod, double rate) {
super(id, name, dem);
pproduced = prod;
prate = rate;
}
public double calculation() {
double amtDemand = prate * pdemand;
double amtProduced = prate * pproduced;
return amtDemand - amtProduced;
}
public void display() {
super.display();
System.out.println("Quantity Produced: " + pproduced);
System.out.println("Rate: " + prate);
System.out.println("Difference in Amount: " + calculation());
}
}
Teacher's Note:
a) Use super() in the subclass constructor to properly initialize inherited data members from the parent class.
b) Invoke super.display() in the overridden display method to reuse parent class display logic.
Question 11
(i) A linked list is formed from the objects of the class given below:
class Node
{
double sal;
Node next;
}
Write an Algorithm OR a Method to add a node at the end of an existing linked list.
The method declaration is as follows:
void addNode(Node ptr, double ss) [2 Marks]
Answer:
public void addNode(Node ptr, double ss) {
Node newNode = new Node();
newNode.sal = ss;
newNode.next = null;
if (ptr == null) {
return;
}
Node temp = ptr;
while (temp.next != null) {
temp = temp.next;
}
temp.next = newNode;
}
Teacher's Note:
a) Traverse the linked list until the last node (where next is null) is reached.
b) Create a new node and attach it to temp.next to successfully append at the end.
(ii) Answer the following questions from the diagram of a Binary Tree given below:
[Figure: Binary tree with root A; A has left child F and right child B; F has left child D and right child G; B has right child H; H has left child E.]
(a) Write the pre-order traversal of the above tree structure. [1 Mark]
Answer: A, F, D, G, B, H, E
Teacher's Note:
a) Pre-order traversal follows the Root -> Left -> Right sequence.
b) Trace recursively starting from root A, visiting left subtree (F, D, G) before right subtree (B, H, E).
(b) Name the parent of the nodes D and B. [1 Mark]
Answer:
- Parent of node D is F.
- Parent of node B is A.
Teacher's Note:
a) The parent is the immediate ancestor node connected directly above a child node.
b) D is the left child of F, and B is the right child of A.
(c) State the level of nodes E and F when the root is at level 0. [1 Mark]
Answer:
- Level of node F is 1.
- Level of node E is 3.
Teacher's Note:
a) Root A is at level 0.
b) F is at level 1, H is at level 2, and E is at level 3.
Free study material for Computer Science
Practice Exam Question Papers for Class 12 Computer Science ISC Class 12 Computer Science Board Exam Question Paper 2023 with Solutions
Class 12 Computer Science Past Exam Papers & Resources
Explore downloadable past papers for Class 12 Computer Science. Utilizing the ISC Class 12 Computer Science Board Exam Question Paper 2023 with Solutions ensures complete preparedness by offering clear insights into historical question styles and marking expectations.
Importance of Solving ISC Class 12 Computer Science Board Exam Question Paper 2023 with Solutions
Reviewing official papers clarifies the exact marking scheme and structural layout established by the ISC, enabling students to structure answers for maximum score potential.
Complete Your Exam Preparation
Pair your past paper revision with our official Class 12 Computer Science sample papers and online practice modules to achieve total curriculum mastery.
FAQs
The ISC Class 12 Computer Science Board Exam Question Paper 2023 with Solutions is available for download on StudiesToday.com. It includes complete set with all sections so that Class 12 students can practice with the exact same paper that came in the ISC exams.
Yes, the solutions for ISC Class 12 Computer Science Board Exam Question Paper 2023 with Solutions are prepared by subject matter experts as per official marking scheme. Class 12 students will understand the structure of answers and 'step-marks' methodology Computer Science.
Solving previous year papers like ISC Class 12 Computer Science Board Exam Question Paper 2023 with Solutions is important to understand repeat themes and question difficulty levels of Computer Science. It helps Class 12 students to test their time management skills too.
Yes, where applicable, ISC Class 12 Computer Science Board Exam Question Paper 2023 with Solutions is available in both English and Hindi mediums. All students from Class 12 can access Computer Science study material in their preferred language.
No, all previous year question papers on StudiesToday, including ISC Class 12 Computer Science Board Exam Question Paper 2023 with Solutions, are provided free of charge in mobile-friendly PDF.