Professional Documents
Culture Documents
COMPUTER SCIENCE
PAPER 1
(THEORY)
Maximum Marks: 35
Time allowed: One and a half hours
Candidates are allowed an additional 10 minutes for only reading the paper.
They must NOT start writing during this time.
----------------------------------------------------------------------------------------------------------------
Answer all questions in Section A, Section B and Section C.
While answering questions in Sections A and B, working and reasoning may be indicated
briefly.
The intended marks for questions or parts of questions are given in brackets. [ ]
All working, including rough work, should be done on the same sheet as the rest of the answer.
SECTION A (7 MARKS)
Question 1
(i) Which of this keyword must be used to invoke a base class constructor? [1]
a) super
b) this
c) super()
d) this()
(ii) Which polymorphism concept is applied to inheritance relationship in java
programming? [1]
a) Method overloading
b) Constructor overloading
c) Method overriding
d) None
With reference to the program code given above what will the function recursive()
return when the value of q=3 and p=27?
a) 1
b) 3
c) 0
d) 27
(iv) Name the data type that is used by operating system to manage the Recursion
in Java? [1]
(v) What is the output of the statement given below: [1]
System.out.println(“Computer Knowledge”.substring(0,8).concat(“Computer
Applications”.substring(9)));
(vi) Write a Java statement to check if the second character of a string str is in
upper case. [1]
(vii) Name the principle by which interruptions are handled by operating systems. [1]
SECTION B (8 MARKS)
Question 2 [2]
A recursive method should have a base case. Explain the reason.
Question 3 [2]
A *N-T+H/E/R
Question 4
Answer the following questions on the diagram of a Binary Tree given below:
Question 5 [6]
(i) A class Order has been defined to arrange all the letters of string in an
alphabetical
order. Now, insert the missing letters in the sorted string to complete all the
letters between first and last characters of the string.
Sample Input:
computer
Alphabetical order:
cemoprtu
Sample Output:
cdefghijklmnopqrstu
Some of the members of the class are given below:
(ii) A class Arrange has been defined to arrange all the letters of string such that
all the lower case characters are followed by the upper case characters.
Sample Input:
Computer Science
Sample Output:
omputercienceCS
Some of the members of the class are given below:
Question 6 [6]
OR
(iii) A happy number is a number in which the eventual sum of the square of the
digits of the number is equal to 1.
Example: 28 = (2)2 + (8)2 = 4 +64 +68
68 = (6)2 + (8)2 = 36 +64 = 100
100 = (1)2 + (0)2 + (0)2 = 1+0+0 =1
Hence, 28 is a happy number.
Example : 12 =(1)2 + (2)2 =1+4 = 5
Hence, 12 is not a happy number.
Design a class Happy to check if a given number is a happy number. Some of
the members of the class are given below.
Class name :Happy
Data members / instance variables :
n :stores the number
Member functions :
Happy() :constructor to assign 0 to n
void getnum(int nn) : to assign the parameter value to the number
n = nn
int sum sq digits(int x) : returns the sum of the square of the digits of
the number using the recursive technique.
void ishappy() : checks if the given number is a happy
number by calling function
sum_sq_digits(int) and displays an
appropriate message
Specify the class Happy, giving details of the constructor(), void getnum(int), and
int sum_sq_di(int) and void ishappy(). Also define a main() function to create an
object and call the methods to check number.
Question 7 [4]
A super class Employee has been defined to store the details of an employee. Define
a subclass Overtime to calculate the amount paid for working more than the normal
hours.
The details of the classes are given below:
Class name : Employee
Data members/instance variables :
empc : To store employee code.
bpy : To store basic salary in double type.
Member functions/methods :
Employee() : Constructor to assign 0 to empc and bpay.
Employee (int c, double b) : Constructor to assign 'c’ to empc and 'b'
bpay.
void show() : To display empc and bpay after performing
the task.
Class name : Overtime
Data members/instance variables:
nd : To store number (int) of days extra worked.
rate : To store rate (float) per day.
Member functions/methods :
Overtime(int n, float r) : Constructor to assign 'n' to nd and 'r' to rate.
double calculate() : To calculate gross salary (basic salary +
salary paid for extra hours).
void show() : To display the amount paid for extra hours.
Assume that the super class Employee has been defined. Using the concept of
inheritance, specify the class Overtime giving the details of the constructor,
double calculate() and void show() functions. The main() function need not be
written.
Question 8 [4]
Specify class WordPile giving details of the constructor and member functions.
The main function and algorithm need not be written .
***********************