Choose the correct option.
- (a)import
- (b)implements
- (c)extends
- (d)include
Show answer
Answer
Correct option: (b)
The ISC 2022 Computer Science - Specimen paper (Semester 2), Paper 1 for Class 12: all 17 questions, 35 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.
Choose the correct option.
Answer
Correct option: (b)
Choose the correct option.
Answer
Correct option: (d)
Choose the correct option.
int Toy(int n)
{ return (n<=0)? 1: n%10 + Toy(n/10); }With reference to the program code given above, what will the function Toy() return when the value of $n = 56$?Answer
Correct option: (b)
Answer the following question.
Answer
Answer the following question.
Answer
What is the output of the following code?
System.out.print("FAN" + ("AUTOMATIC".charAt(5)));Answer
Answer the following question.
Answer
Differentiate between the following.
Answer
Convert the following notation as directed.
Answer
Answer the following questions from the binary tree.
Answer
Answer the following questions from the binary tree.
Answer
Write the program described below.
Answer
import java.util.*;
class Check
{
String wrd;
int len;
Check()
{
wrd = "";
len = 0;
}
void acceptword()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter a word: ");
wrd = sc.next();
len = wrd.length();
}
boolean palindrome()
{
for (int i = 0; i < len / 2; i++)
if (wrd.charAt(i) != wrd.charAt(len - 1 - i))
return false;
return true;
}
void display()
{
if (palindrome())
System.out.println(wrd + " is a palindrome word");
else
System.out.println(wrd + " is not a palindrome word");
}
public static void main(String[] args)
{
Check ob = new Check();
ob.acceptword();
ob.display();
}
}The method palindrome() compares the characters from both ends moving towards the middle; any mismatch returns false. Sample run: MADAM gives "MADAM is a palindrome word".Write the program described below.
Answer
import java.util.*;
class Toggle
{
String str, newstr;
int len;
Toggle()
{
str = "";
newstr = "";
len = 0;
}
void readword()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter a word: ");
str = sc.next();
len = str.length();
}
void toggle()
{
newstr = "";
for (int i = 0; i < len; i++)
{
char ch = str.charAt(i);
if (Character.isUpperCase(ch))
newstr = newstr + Character.toLowerCase(ch);
else if (Character.isLowerCase(ch))
newstr = newstr + Character.toUpperCase(ch);
else
newstr = newstr + ch;
}
}
void display()
{
System.out.println("Original word: " + str);
System.out.println("Toggled word: " + newstr);
}
public static void main(String[] args)
{
Toggle ob = new Toggle();
ob.readword();
ob.toggle();
ob.display();
}
}Each character is checked and its case reversed and appended to newstr. Sample run: mOTivATe gives MotIVatE.Write the program described below.
Answer
import java.util.*;
class Fibo
{
int start, end;
Fibo()
{
start = 0;
end = 0;
}
void read()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter start: ");
start = sc.nextInt();
System.out.print("Enter end: ");
end = sc.nextInt();
}
int fibo(int n)
{
if (n <= 1)
return n;
return fibo(n - 1) + fibo(n - 2);
}
void display()
{
System.out.println("Fibonacci series from " + start + " to " + end + ":");
int i = 0, t = fibo(0);
while (t <= end)
{
if (t >= start)
System.out.print(t + " ");
i++;
t = fibo(i);
}
System.out.println();
}
public static void main(String[] args)
{
Fibo ob = new Fibo();
ob.read();
ob.display();
}
}fibo(n) is recursive: fibo(0) = 0, fibo(1) = 1, otherwise the sum of the previous two terms. display() prints the terms that lie between start and end. Sample run: start 2, end 50 gives 2 3 5 8 13 21 34.Write the program described below.
Answer
import java.util.*;
class Gcd
{
int num1, num2;
Gcd()
{
num1 = 0;
num2 = 0;
}
void accept()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter first number: ");
num1 = sc.nextInt();
System.out.print("Enter second number: ");
num2 = sc.nextInt();
}
int gcd(int x, int y)
{
if (y == 0)
return x;
return gcd(y, x % y);
}
void display()
{
System.out.println("GCD of " + num1 + " and " + num2 + " = " + gcd(num1, num2));
}
public static void main(String[] args)
{
Gcd ob = new Gcd();
ob.accept();
ob.display();
}
}The recursive method uses Euclid's algorithm: gcd(x, y) = gcd(y, x % y) until y becomes 0. Sample run: 48 and 18 gives 6.Write the program described below.
Answer
class Update extends Godown
{
int pur_qty;
double pur_rate;
Update(String i, int q, double r, int pq, double pr)
{
super(i, q, r);
pur_qty = pq;
pur_rate = pr;
}
void update()
{
qty = qty + pur_qty;
if (rate != pur_rate)
rate = pur_rate;
amt = qty * rate;
}
void display()
{
System.out.println("Stock before updating:");
super.display();
update();
System.out.println("Stock after updating:");
super.display();
}
}The constructor passes the stock details to Godown using super(). update() adds the purchased quantity, replaces the rate if it differs and recomputes the stock value as quantity * rate. display() shows the stock before and after the update. (Assumes rate and amt are double and qty is int in Godown.)Write the program described below.
Answer
void add_dat(int v)
{
if (rear < cap)
{
dat[rear] = v;
rear++;
}
else
System.out.println("Queue full");
}
int pop_dat()
{
if (front == rear)
return -999;
int v = dat[front];
front++;
return v;
}Elements are added at index rear while rear is less than cap; otherwise "Queue full" is displayed. Elements are removed from index front, and -999 is returned when the queue is empty (front equals rear).The ISC 2022 Computer Science - Specimen paper (Semester 2), Paper 1 is a specimen paper for Class 12: 17 questions in printed order, 35 marks in all, asked from 5 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.
| Section | Questions | Marks printed* |
|---|---|---|
| A | 7 | 7 |
| B | 4 | 8 |
| C | 6 | 32 |
| Kind | Questions | Marks printed* |
|---|---|---|
| Program | 6 | 32 |
| Binary tree | 2 | 4 |
| MCQ | 3 | 3 |
| Short answer | 3 | 3 |
| Differentiate | 1 | 2 |
| Conversion | 1 | 2 |
| Output | 1 | 1 |
| Chapter | Questions | Marks printed* |
|---|---|---|
| Recursion | 5 | 16 |
| Objects | 2 | 12 |
| Data structures | 5 | 11 |
| Inheritance, Interfaces and Polymorphism | 3 | 6 |
| Arrays, Strings | 2 | 2 |
* 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.
17 questions, 35 marks in all, shown in full and in printed order on this page.
By number of questions: Recursion (5), Data structures (5), Inheritance, Interfaces and Polymorphism (3) and Objects (2).
Tap “Show answer” under a question to see its answer. The download button saves the paper as a PDF, with or without the answers.