This is a complete ISC Class 12 Computer Science (Paper 1 – Theory) sample paper for 2027. It follows the structure of recent CISCE papers. Attempt it in 3 hours without looking at the solutions, and then check every answer against the fully worked solutions at the end.
Paper Pattern
- Maximum Marks: 70 (Theory). The practical exam carries a further 30 marks.
- Time Allowed: 3 hours (plus 15 minutes reading time)
- Part I (20 marks): Compulsory. Question 1 has 10 MCQs (1 mark each). Question 2 has 5 short-answer questions (2 marks each).
- Part II (50 marks): Section A covers Boolean algebra (15 marks). Section B covers Java programming: attempt any two of three questions (20 marks). Section C covers data structures (15 marks).
COMPUTER SCIENCE – PAPER 1 (THEORY) – SAMPLE PAPER 2027
Class XII | Maximum Marks: 70 | Time Allowed: Three Hours
Candidates are allowed an additional 15 minutes for reading the paper only. They must NOT start writing during this time.
Answer all questions in Part I (compulsory) and the questions from Part II as instructed in each section. Programs must be written in Java. The intended marks for questions or parts of questions are given in brackets [ ].
PART I – 20 Marks (Answer all questions)
Question 1 – Multiple Choice Questions [10 × 1]
(i) What is the dual of the Boolean expression X + 0 = X?
- (a) X · 0 = X
- (b) X · 1 = X
- (c) X + 1 = 1
- (d) X' + 1 = X
(ii) The expression A + A'B simplifies to:
- (a) A
- (b) B
- (c) A + B
- (d) AB
(iii) What is the converse of the proposition p ⇒ q?
- (a) q ⇒ p
- (b) ~p ⇒ ~q
- (c) ~q ⇒ ~p
- (d) p ⇒ ~q
(iv) An array A[15][20] is stored in row-major order. Each element takes 2 bytes and the base address is 1000. The lower bounds are 0. What is the address of A[5][8]?
- (a) 1108
- (b) 1216
- (c) 1232
- (d) 1316
(v) What is the worst-case time complexity of binary search on n elements?
- (a) O(1)
- (b) O(n)
- (c) O(log n)
- (d) O(n²)
(vi) What is the postfix form of (A + B) * C − D / E?
- (a) A B + C * D E / −
- (b) A B C + * D E / −
- (c) + A B * C − / D E
- (d) A B + C D E / * −
(vii) Which of the following is NOT a wrapper class in Java?
- (a) Integer
- (b) Character
- (c) String
- (d) Double
(viii) What value is returned by fun(7) for the method below?
int fun(int n) {
if (n <= 1)
return 1;
return n + fun(n - 2);
}- (a) 15
- (b) 16
- (c) 28
- (d) 7
(ix) Which data structure follows the LIFO principle?
- (a) Queue
- (b) Stack
- (c) Dequeue
- (d) Binary tree
(x) Assertion (A): A subclass constructor can call the superclass constructor using super(). Reason (R): The call to super() must be the first statement in the subclass constructor.
- (a) Both A and R are true, and R is the correct explanation of A
- (b) Both A and R are true, but R is not the correct explanation of A
- (c) A is true but R is false
- (d) A is false but R is true
Question 2 – Short Answer Questions [5 × 2]
(i) State two differences between an interface and an abstract class. [2]
(ii) Differentiate between a static data member and an instance data member. [2]
(iii) Convert the following infix expression into its prefix form: A * (B + C) / D [2]
(iv) Give the output of the following code: [2]
String s = "Programming";
System.out.println(s.indexOf('g', 4) + " " + s.lastIndexOf('m'));(v) An array A[1…10][1…15] is stored in column-major order. Each element takes 4 bytes and the base address is 2000. Find the address of A[4][6]. [2]
PART II – 50 Marks
SECTION A – Boolean Algebra (Answer all questions)
Question 3 [5]
(a) Using a truth table, verify that (p ⇒ q) ∧ (q ⇒ p) ≡ p ⇔ q. [3]
(b) What is a half adder? Write the Boolean expressions for its Sum and Carry outputs. [2]
Question 4 [10]
(a) Given F(A, B, C, D) = Σ(0, 2, 5, 7, 8, 10, 13, 15): [5]
- Reduce F using a four-variable Karnaugh map, showing the groups formed. [4]
- Draw the logic gate diagram for the reduced expression. [1]
(b) Given F(P, Q, R) = π(0, 1, 3, 5), reduce F to its simplest Product-of-Sums form using a K-map. [3]
(c) Prove algebraically that (A + B)(A + C) = A + BC. [2]
SECTION B – Java Programming (Answer any two questions)
Question 5 [10]
A Harshad (Niven) number is divisible by the sum of its digits. Example: 156, because 1 + 5 + 6 = 12 and 156 ÷ 12 = 13.
Design a class Harshad with the following details:
- Data member:
int n(stores the number) - Harshad(int nn): parameterised constructor that assigns nn to n
- int sumDigits(int x): returns the sum of the digits of x using a recursive technique
- void check(): checks and prints whether n is a Harshad number, using sumDigits()
Specify the class Harshad and write the main() function.
Question 6 [10]
Design a class WordSort that accepts a sentence ending with a full stop and prints its words in alphabetical order.
- Data members:
String sent,String words[],int count - void accept(): to input the sentence in uppercase
- void sortWords(): to extract the words into the array and sort them alphabetically using bubble sort
- void display(): to print the sorted words
Example input: THE QUICK BROWN FOX. gives the output BROWN FOX QUICK THE
Question 7 [10]
Design a class SymMat to check whether a square matrix is symmetric. A matrix is symmetric if a[i][j] = a[j][i] for every i and j. Also find the sum of the left diagonal and the sum of the right diagonal.
- Data members:
int m[][],int n(order of the matrix, where 2 < n < 10) - SymMat(int nn): constructor that sets n and creates the matrix
- void input(): to input the elements of the matrix
- boolean isSymmetric(): returns true if the matrix is symmetric
- void diagonals(): prints the sum of each diagonal
Specify the class and write the main() function.
SECTION C – Data Structures (Answer all questions)
Question 8 – Inheritance [5]
A superclass Account has the data members name, accNo and principal. Define a subclass Savings with the data members rate and time, and a method void calculate() that computes the compound interest. Override display() to show all the details. Use the super keyword appropriately.
Specify the class Savings only. Assume that the class Account is already defined.
Question 9 – Stack [5]
A stack is a linear data structure that allows insertion and deletion at one end only (the top). Define a class Stack with:
- Data members:
int arr[],int cap(capacity) andint top - Stack(int c): constructor that sets cap and initialises top to −1
- void push(int v): pushes v onto the stack, or prints "Stack Overflow" if it is full
- int pop(): removes and returns the top element, or returns −9999 if it is empty
Specify the class Stack (the main() function is not required).
Question 10 – Linked List and Binary Tree [5]
(a) A linked list is formed from objects of the class Node shown below. Write a method int count(Node start) that returns the number of nodes in the list. [2]
class Node {
int data;
Node next;
}(b) Answer the following questions about the binary tree given below: [3]
A
/ \
B C
/ \ \
D E F- Write the preorder, inorder and postorder traversals.
- Name the leaf nodes.
- What is the height of the tree?
SOLUTIONS
Attempt the full paper before checking these.
Solutions to Question 1
(i) (b) X · 1 = X. To find the dual, swap + with ·, and swap 0 with 1.
(ii) (c) A + B. A + A'B = (A + A')(A + B) = 1 · (A + B) = A + B, using the distributive law.
(iii) (a) q ⇒ p. The converse swaps the antecedent and the consequent.
(iv) (b) 1216. Address = B + W[(I − Lr) × C + (J − Lc)] = 1000 + 2[(5 × 20) + 8] = 1000 + 2 × 108 = 1216.
(v) (c) O(log n). Each comparison halves the search space.
**(vi) (a) A B + C * D E / −.**
(vii) (c) String. String is a class, but it does not wrap a primitive type.
(viii) (b) 16. fun(7) = 7 + fun(5) = 7 + 5 + fun(3) = 7 + 5 + 3 + fun(1) = 7 + 5 + 3 + 1 = 16.
(ix) (b) Stack.
(x) (b). Both statements are true, but R is a rule about where the call must be placed. It does not explain why the call is possible.
Solutions to Question 2
(i)
- All the methods of an interface are abstract by default (apart from default and static methods). An abstract class can have both abstract and concrete methods.
- A class can implement many interfaces, but it can extend only one abstract class. (Another accepted difference: interface variables are always public, static and final.)
(ii) A static data member is declared with the keyword static. Only one copy exists, and it is shared by all objects of the class. An instance data member gets a separate copy in each object.
(iii)
A * (B + C) / D
= A * (+BC) / D
= (*A+BC) / D
= / * A + B C DPrefix: / * A + B C D
(iv) Output: 10 7
The indices of "Programming" are P0 r1 o2 g3 r4 a5 m6 m7 i8 n9 g10. Searching for 'g' from index 4 finds it at index 10. The last 'm' is at index 7.
(v) In column-major order: Address = B + W[(J − Lc) × R + (I − Lr)], where R = 10 rows.
= 2000 + 4 × [(6 − 1) × 10 + (4 − 1)]
= 2000 + 4 × 53
= 2212Solution to Question 3
(a)
p q | p⇒q | q⇒p | (p⇒q)∧(q⇒p) | p⇔q
T T | T | T | T | T
T F | F | T | F | F
F T | T | F | F | F
F F | T | T | T | TThe last two columns are identical. Hence (p ⇒ q) ∧ (q ⇒ p) ≡ p ⇔ q. Hence verified.
(b) A half adder is a combinational circuit that adds two single bits A and B and produces a Sum and a Carry.
- Sum = A ⊕ B = A'B + AB'
- Carry = A · B
A B | Sum Carry
0 0 | 0 0
0 1 | 1 0
1 0 | 1 0
1 1 | 0 1Solution to Question 4

(a) The K-map for F(A, B, C, D) = Σ(0, 2, 5, 7, 8, 10, 13, 15):
C'D' C'D CD CD'
A'B' | 1 | 0 | 0 | 1 |
A'B | 0 | 1 | 1 | 0 |
AB | 0 | 1 | 1 | 0 |
AB' | 1 | 0 | 0 | 1 |- Quad 1 (the four corners): m0, m2, m8, m10. B = 0 and D = 0 throughout, which gives B'D'.
- Quad 2 (the centre): m5, m7, m13, m15. B = 1 and D = 1 throughout, which gives BD.
F(A, B, C, D) = B'D' + BD, which is the XNOR of B and D.
Logic diagram: B and D each pass through a NOT gate to give B' and D'. One AND gate takes B' and D', and another AND gate takes B and D. The two AND outputs feed into an OR gate, whose output is F. A single XNOR gate with inputs B and D gives the same result.
(b) Mark 0 in the cells for the maxterms 0, 1, 3 and 5:
- Pair (M0, M1): P = 0 and Q = 0 throughout, which gives (P + Q)
- Pair (M1, M3): P = 0 and R = 1 throughout, which gives (P + R')
- Pair (M1, M5): Q = 0 and R = 1 throughout, which gives (Q + R')
F(P, Q, R) = (P + Q) · (P + R') · (Q + R'). All three pairs are essential, because M0, M3 and M5 can each be covered by only one pair.
(c)
LHS = (A + B)(A + C)
= A·A + A·C + A·B + B·C
= A + AC + AB + BC [A·A = A]
= A(1 + C + B) + BC
= A·1 + BC [1 + X = 1]
= A + BC = RHSSolution to Question 5
import java.util.Scanner;
class Harshad {
int n;
Harshad(int nn) {
n = nn;
}
int sumDigits(int x) {
if (x == 0)
return 0; // base case
return x % 10 + sumDigits(x / 10); // recursive case
}
void check() {
int s = sumDigits(n);
if (s != 0 && n % s == 0)
System.out.println(n + " is a Harshad number");
else
System.out.println(n + " is not a Harshad number");
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
Harshad ob = new Harshad(sc.nextInt());
ob.check();
}
}Sample output: for 156 the program prints "156 is a Harshad number", because the digit sum is 12 and 156 % 12 = 0.
Solution to Question 6
import java.util.Scanner;
import java.util.StringTokenizer;
class WordSort {
String sent;
String words[];
int count;
void accept() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a sentence: ");
sent = sc.nextLine().trim().toUpperCase();
}
void sortWords() {
StringTokenizer st = new StringTokenizer(sent, " .");
count = st.countTokens();
words = new String[count];
for (int i = 0; i < count; i++)
words[i] = st.nextToken();
for (int i = 0; i < count - 1; i++) {
for (int j = 0; j < count - 1 - i; j++) {
if (words[j].compareTo(words[j + 1]) > 0) {
String t = words[j];
words[j] = words[j + 1];
words[j + 1] = t;
}
}
}
}
void display() {
for (int i = 0; i < count; i++)
System.out.print(words[i] + " ");
System.out.println();
}
public static void main(String args[]) {
WordSort ob = new WordSort();
ob.accept();
ob.sortWords();
ob.display();
}
}Solution to Question 7
import java.util.Scanner;
class SymMat {
int m[][];
int n;
SymMat(int nn) {
n = nn;
m = new int[n][n];
}
void input() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter " + (n * n) + " elements:");
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
m[i][j] = sc.nextInt();
}
boolean isSymmetric() {
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (m[i][j] != m[j][i])
return false;
return true;
}
void diagonals() {
int left = 0, right = 0;
for (int i = 0; i < n; i++) {
left += m[i][i];
right += m[i][n - 1 - i];
}
System.out.println("Sum of left diagonal: " + left);
System.out.println("Sum of right diagonal: " + right);
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the order of the matrix: ");
int size = sc.nextInt();
if (size <= 2 || size >= 10) {
System.out.println("Size out of range");
return;
}
SymMat ob = new SymMat(size);
ob.input();
if (ob.isSymmetric())
System.out.println("The matrix is symmetric");
else
System.out.println("The matrix is not symmetric");
ob.diagonals();
}
}Solution to Question 8
class Savings extends Account {
double rate, time, interest;
Savings(String nm, long acc, double p, double r, double t) {
super(nm, acc, p); // initialise the superclass members
rate = r;
time = t;
}
void calculate() {
double amount = principal * Math.pow(1 + rate / 100, time);
interest = amount - principal;
}
void display() {
super.display(); // show name, account number and principal
System.out.println("Rate: " + rate + "% Time: " + time + " years");
System.out.println("Compound Interest: " + interest);
}
}Note: the superclass members (name, accNo and principal) must be declared protected in Account for the subclass to use principal directly.Solution to Question 9
class Stack {
int arr[];
int cap, top;
Stack(int c) {
cap = c;
arr = new int[cap];
top = -1;
}
void push(int v) {
if (top == cap - 1)
System.out.println("Stack Overflow");
else
arr[++top] = v;
}
int pop() {
if (top == -1)
return -9999; // Stack Underflow
return arr[top--];
}
}Solution to Question 10

(a)
int count(Node start) {
int c = 0;
Node temp = start;
while (temp != null) {
c++;
temp = temp.next;
}
return c;
}(b)
- Preorder (Root, Left, Right): A B D E C F
- Inorder (Left, Root, Right): D B E A C F
- Postorder (Left, Right, Root): D E B F C A
- Leaf nodes: D, E and F
- Height: 2, counting the edges on the longest path from the root to a leaf. Some textbooks count levels instead, which gives 3.
How to Use This Paper Effectively
- Attempt the paper in one sitting so you get used to the 3-hour timing.
- In Section A, always draw the K-map grid and label each group. Step marks are given.
- In Section B, write the class description (data members and member methods) before the code.
- In Section C, write a complete method or clear algorithm steps. Partial code still earns marks.
Looking for more? Explore our ISC Class 12 solved programs and practical papers to practise previous years' questions.

