Chapter Questions

Computer Science - 10 Years Solved Papers ISC Class XII Questions

Explore chapter-wise explanatory questions and quickly move between related subchapters from a cleaner, more advanced layout.

Questions List

Browse all explanatory questions of this chapter.

36 Total Questions
1

[String Tokenizer]

Question:

What is the difference between the two methods, nextToken() and hasMoreTokens() of StringTokenizer class?


Question ID: 11339 Read Details
2

[Operation on File]

Question:

What is the difference between the following two statements?

1. FileWriter fw = new FileWriter();

2. FileWriter fw = new FileWriter(, true);

Question ID: 11338 Read Details
3

[Recursion]

Question:

A student has written the following code. It is written to check whether a string is palindrome or not. However, the code is not giving the desired result when the parameter “MADAM” is passed to the method isPalindrome(). Analyse the code and find out the logical error.

public class PalindromeTesting
{
    public static boolean isPalindrome(String word)
    {
        if(word.length() < 1)
        {
            return true;
        }

        else if(word.charAt(0) != word.charAt(word.length() - 1))
        {
            return false;
        }

        else
        {
            return isPalindrome(word.substring(0, word.length() - 1));
        }
    }
}

Question ID: 11337 Read Details
4

[Recursion]

Question:

Following method is a part of a class MyArray.

int check(int m[ ], int i)
{
    if(i <= 0)
    {
        return 0;
    }

    return check(m, i-2) + m[i-1];
}

public static void main()
{
    int m[ ] = {1, 2, 3, 4};

    int ans = check(m, m.length);

    System.out.println(ans);
}

(a) Predict the output of the code considering there is no compilation error. Show the working.

(b) Considering the if condition is changed to if(i < 0), how will it affect the output?

Question ID: 11336 Read Details
5

[Computer Hardware]

Question:

Draw the logic circuit diagram for the simplified form of the following expression:

AB'C + AB'C + ABC

The circuit diagram should only contain:

  • One AND gate
  • One OR gate
  • One NOT gate

Question Diagram:


Expression:

AB'C + AB'C + ABC


Answer:

Step 1: Simplification

AB'C + AB'C + ABC

= AB'C + ABC

= A(B'C + BC)

= AC

Simplified Expression:

AC

Question ID: 11335 Read Details
6

[Computer Hardware]

Question:

Following is the circuit diagram of a Full Adder. Redraw the circuit diagram by adding the missing logic gates.

Diagram of a full adder
Figure: Diagram of a full adder

Question ID: 11334 Read Details
7

[Computer Hardware]

Question:

Write the canonical Product-of-Sum (POS) expression for the Sum and Carry of a Full Adder.

Question ID: 11333 Read Details
8

[Computer Hardware]

Question:

A 2 to 4 decoder contains 2 inputs denoted by A1 and A0 and 4 outputs denoted by D0, D1, D2, D3. Write the minterm representations for D1 and D3.

Question ID: 11332 Read Details
9

[Packages]

Question:

Given the following code snippet:

package mine;

public class Greetings
{
    public static void greet(String name)
    {
        System.out.println("Hello " + name + 
        ", welcome to the world of programming");
    }
}
import java.util.*;
import mine.*;

public class Trial
{
    public static void main()
    {
        Scanner sc = new Scanner(System.in);

        System.out.println("Give your name");

        String n = sc.next();

        Greetings.greet(n);
    }
}

(a) Predict the output for n = "Abhay".

(b) Explain the difference between:

import java.util.*;

and

import mine.*;

Question ID: 11331 Read Details
10

[Packages]

Question:

State the purpose of the following keywords in Java:

(a) package
(b) import

Question ID: 11330 Read Details
11

[Packages]

Question:

Why is the lang package termed as the default package in Java?

Question ID: 11329 Read Details
12

[String]

Question:

Find the output of the following snippet:

String S1 = "AB", S2 = "BC";

for(int i = 0, j = 0; i < S1.length(); i++, j++)
{
    System.out.println(S1.charAt(i) + S2.charAt(j));
}

Question ID: 11328 Read Details
13

[String]

Question:

How many String objects are created in the following snippet? Justify your answer.

String s1 = "Gujarat";

String s2 = new String("Gujarat");

String s3 = new String("Gujarat");

String s4 = "Gujarat";

Question ID: 11327 Read Details
14

[Arrays]

Question:

What is the length of the array int arr[], if its first index is x and the last index is y?

Question ID: 11326 Read Details
15

[String]

Question:

Find the output:

System.out.println(
    "RocKet".substring(0, 4)
    .compareTo("Rock".replace('m', 'o'))
);

Question ID: 11325 Read Details
16

[String]

Question:

Write the Java statement to print the position of the 2nd occurrence of the letter 'I' within the word "MICHIGAN".

Question ID: 11324 Read Details
17

[String and Arrays]

Question:

Find the output of the following snippet:

void check1()
{
    String x[] = {"Kolkata","Chennai","Delhi"};
    String y[] = {"Kolkata","Chennai","Delhi"};

    System.out.println(x.equals(y));
}

Answer:

false

Question ID: 11323 Read Details
18

[Computational Complexity and Big-O Notation]

Question:

Finding the greatest common divisor (GCD) of two positive integers results in the time complexity of O(log N), where N is the larger number of two inputs. Justify the statement.

Question ID: 11135 Read Details
19

Question:

A student had written the following method to display “Hello World” four times:

void displayMessage()
{
    System.out.println("Hello World");
    System.out.println("Hello World");
    System.out.println("Hello World");
    System.out.println("Hello World");
}

Later, the student modified the code using a loop:

void displayMessage()
{
    int i = 1;
    while(i <= 4)
    {
        System.out.println("Hello World");
        i++;
    }
}

Compare the above code snippets with respect to time complexity.

Question ID: 11134 Read Details
20

Question:

Finding the greatest common divisor (GCD) of two positive integers results in the time complexity of O(log N), where N is the larger number of two inputs. Justify the statement.

Question ID: 11133 Read Details
21

[Computational Complexity and Big-O Notation]

Consider the following snippet, calculate the time complexity:
double m = 1, n = 1;

for(int i = 0; i < x; i++)
{
    m *= Math.random();
}

for(int j = 0; j < y; j++)
{
    n *= Math.random();
}
    

Question ID: 11132 Read Details
22

[Primitive Values, Wrapper Classes, Types and Casting]

Complete the code of TeacherA and name the technique used:
TeacherA:
int average = ( ____ )((m1 + m2 + m3) / 3);

TeacherB:
int average = Math.round((m1 + m2 + m3) / 3);

Question ID: 11131 Read Details
23

[Primitive Values, Wrapper Classes, Types and Casting]

While using Wrapper classes, we do not need to import any package. Give a reason.

Question ID: 11130 Read Details
24

[Primitive Values, Wrapper Classes, Types and Casting]

What gets printed?
char[] set = {'*','D','5'};
System.out.print(Character.isDigit(set[2]) + " ");
System.out.print(Character.isWhitespace(set[0]) + " ");
System.out.print(Character.isLetterOrDigit(set[1]));

Question ID: 11129 Read Details
25

[Primitive Values, Wrapper Classes, Types and Casting]

Identify the most suitable data type (without losing precision and using memory efficiently) for:

(a) Population of a country
(b) Interest rate in a bank account

Question ID: 11128 Read Details
26

[Primitive Values, Wrapper Classes, Types and Casting]

The following statement will generate a compile time error. This can be rectified in 2 different ways, without losing precision of price. Write these statements:
float price = 17.99;

Question ID: 11127 Read Details
27

[Primitive Values, Wrapper Classes, Types and Casting]

Since a byte can represent 256 different numbers, why is its maximum value 127?

Question ID: 11126 Read Details
28

[Primitive Values, Wrapper Classes, Types and Casting]

How many bytes of data is passed when public void stu_data(int, double, char) is invoked?

Question ID: 11125 Read Details
29

[Primitive Values, Wrapper Classes, Types and Casting]

Following is a code to convert a String into Double. Fill the missing parts of the code:
________ str = "15.45"; double d = __________ (Double.parseDouble(str));

Question ID: 11124 Read Details
30

[Polymorphism]

In the given code snippet, which feature of object‑oriented programming concept is being exhibited by the substring() method?
String s = "sandwich"; System.out.println(s.substring(4)); System.out.println(s.substring(1,4));

Question ID: 11123 Read Details
31

[Inheritance]

Based on the given image, write the Java statement to create the class Child.
Inheritance

Question ID: 11122 Read Details
32

[Interface]

All methods declared in an interface are abstract. Where will the body of these abstract methods be defined?

Question ID: 11121 Read Details
33

[Inheritance]

What will happen if method void show() in subclass Car is given access specifier as private?

Question ID: 11120 Read Details
34

[Inheritance]

What will happen if data members of the super class are made private instead of protected?

Question ID: 11119 Read Details
35

[Inheritance]

Study the given two classes below and identify the error, if any, in the given code.

class Vehicle
{
    protected String colour;
    protected String registration;

    public Vehicle(String c, String r)
    {
        colour = c;
        registration = r;
    }

    public void show()
    {
        System.out.println("Colour: " + colour);
        System.out.println("Registration number: " + registration);
    }
}

class Car extends Vehicle
{
    private double weight;
    private String model;

    public Car(String model, double weight,
               String colour, String registration)
    {
        this.model = model;
        this.weight = weight;

        super(colour, registration);
    }

    public void show()
    {
        super.show();

        System.out.println("Car Model name = " + model);
        System.out.println("Car body weight = " + weight);
    }
}

  

Question ID: 11118 Read Details
36

ISC Class 12 Computer Science Solved Paper 2026 — Question 1

Question ID: 11117 Read Details