SlideShare a Scribd company logo
---------------------------------------------------------------------------------------------------------------------
This Paper consists of 9 printed pages and 1 blank page.
1217-868 A Turn over
© Copyright reserved.
COMPUTER SCIENCE
PAPER 1
(THEORY)
(Maximum Marks: 70)
(Time allowed: Three hours)
(Candidates are allowed additional 15 minutes for only reading the paper.
They must NOT start writing during this time.)
-------------------------------------------------------------------------------------------------------------------------------
Answer all questions in Part I (compulsory) and six questions from Part-II, choosing two
questions from Section-A, two from Section-B and two from Section-C .
All working, including rough work, should be done on the same sheet as the
rest of the answer.
The intended marks for questions or parts of questions are given in brackets [ ].
---------------------------------------------------------------------------------------------------------------------
PART I (20 Marks)
Answer all questions.
While answering questions in this Part, indicate briefly your working and reasoning,
wherever required.
Question 1
(a) State the law represented by the following proposition and prove it with the help
of a truth table:
P V P = P
[1]
(b) State the Principle of Duality. [1]
(c) Find the complement of the following Boolean expression using De Morgan’s law:
F(a,b,c) = (bʹ + c) + a
[1]
(d) Draw the logic diagram and truth table for a 2 input XNOR gate. [1]
(e) If (~P => Q) then write its: [1]
(i) Inverse
(ii) Converse
-------------------------------------------------------------------------------------------------------------------------------
2
1217-868A
Question 2
(a) What is an interface? How is it different from a class? [2]
(b) Convert the following infix expression to postfix form:
P * Q / R + (S + T)
[2]
(c) A matrix P[15][10] is stored with each element requiring 8 bytes of storage. If the
base address at P[0][0] is 1400, determine the address at P[10][7] when the matrix
is stored in Row Major Wise.
[2]
(d) (i) What is the worst case complexity of the following code segment:
for (int x = 1; x <=a; x++)
{
statements;
}
for (int y = 1; y <=b; y++)
{
for (int z = 1; z <=c; z++)
{
statements;
}
}
[2]
(ii) How would the complexity change if all the three loops went to N instead of
a, b and c?
(e) Differentiate between a constructor and a method of a class. [2]
Question 3
The following function magicfun( ) is a part of some class. What will the function
magicfun( ) return, when the value of n=7 and n=10, respectively? Show the dry
run/working:
int magicfun( int n)
{ if ( n= = 0)
return 0;
else
return magicfun(n/2) * 10 + (n % 2);
}
[5]
-------------------------------------------------------------------------------------------------------------------------------
3
1217-868A Turn over
PART – II (50 Marks)
Answer six questions in this part, choosing two questions from
Section A, two from Section B and two from Section C.
SECTION - A
Answer any two questions.
Question 4
(a) Given the Boolean function F(A, B, C, D) = Ʃ (2,3,4,5,6,7,8,10,11).
(i) Reduce the above expression by using 4-variable Karnaugh map, showing
the various groups (i.e. octal, quads and pairs).
[4]
(ii) Draw the logic gate diagram for the reduced expression. Assume that the
variables and their complements are available as inputs.
[1]
(b) Given the Boolean function F(P, Q, R, S) = 𝝅(0,1,2,4,5,6,8,10).
(i) Reduce the above expression by using 4-variable Karnaugh map, showing
the various groups (i.e. octal, quads and pairs).
[4]
(ii) Draw the logic gate diagram for the reduced expression. Assume that the
variables and their complements are available as inputs.
[1]
Question 5
(a) A school intends to select candidates for an Inter-School Essay Competition as
per the criteria given below:
 The student has participated in an earlier competition and is very
creative.
OR
 The student is very creative and has excellent general awareness, but
has not participated in any competition earlier.
OR
 The student has excellent general awareness and has won prize in an
inter-house competition.
The inputs are:
INPUTS
A participated in a competition earlier
B is very creative
C won prize in an inter-house competition
D has excellent general awareness
(In all the above cases 1 indicates yes and 0 indicates no).
Output : X [1 indicates yes, 0 indicates no for all cases]
Draw the truth table for the inputs and outputs given above and write the POS
expression for X(A,B,C,D).
[5]
-------------------------------------------------------------------------------------------------------------------------------
4
1217-868A
(b) State the application of a Half Adder. Draw the truth table and circuit diagram for a
Half Adder.
[3]
(c) Convert the following Boolean expression into its canonical POS form:
F(A,B,C) = ( B + Cʹ) · (Aʹ + B)
[2]
Question 6
(a) What is a Multiplexer? How is it different from a decoder? Draw the circuit
diagram for a 8:1 Multiplexer.
[5]
(b) Prove the Boolean expression using Boolean laws. Also, mention the law used at
each step.
F = (xʹ + z) + [ (yʹ + z) • (xʹ + y) ]ʹ = 1
[3]
(c) Define maxterms and minterms. Find the maxterm and minterm when:
P = 0, Q = 1, R = 1 and S = 0
[2]
SECTION – B
Answer any two questions.
Each program should be written in such a way that it clearly depicts the logic of the problem.
This can be achieved by using mnemonic names and comments in the program.
(Flowcharts and Algorithms are not required.)
The programs must be written in Java.
Question 7
A class Palin has been defined to check whether a positive number is a Palindrome
number or not.
The number ‘N’ is palindrome if the original number and its reverse are same.
Some of the members of the class are given below:
[10]
Class name : Palin
Data members/instance variables:
num : integer to store the number
revnum : integer to store the reverse of the number
Methods/Member functions:
Palin( ) : constructor to initialize data members with
legal initial values
void accept( ) : to accept the number
int reverse(int y) : reverses the parameterized argument ‘y’ and
stores it in ‘revnum’ using recursive
technique
void check( ) : checks whether the number is a Palindrome by
invoking the function reverse( ) and display
the result with an appropriate message
-------------------------------------------------------------------------------------------------------------------------------
5
1217-868A Turn over
Specify the class Palin giving the details of the constructor( ), void accept( ),
int reverse( int ) and void check( ). Define the main( ) function to create an object and
call the functions accordingly to enable the task.
Question 8
A class Adder has been defined to add any two accepted time.
Example: Time A - 6 hours 35 minutes
Time B - 7 hours 45 minutes
Their sum is - 14 hours 20 minutes ( where 60 minutes = 1 hour)
The details of the members of the class are given below:
[10]
Class name : Adder
Data member/instance variable:
a[ ] : integer array to hold two elements (hours and
minutes)
Member functions/methods:
Adder( ) : constructor to assign 0 to the array elements
void readtime( ) : to enter the elements of the array
void addtime( Adder X, Adder Y) : adds the time of the two parameterized objects
X and Y and stores the sum in the current
calling object
void disptime( ) : displays the array elements with an appropriate
message (i.e. hours = and minutes = )
Specify the class Adder giving details of the constructor( ), void readtime( ),
void addtime(Adder, Adder) and void disptime( ). Define the main( ) function to create
objects and call the functions accordingly to enable the task.
-------------------------------------------------------------------------------------------------------------------------------
6
1217-868A
Question 9
A class SwapSort has been defined to perform string related operations on a word input.
Some of the members of the class are as follows:
[10]
Class name : SwapSort
Data members/instance variables:
wrd : to store a word
len : integer to store length of the word
swapwrd : to store the swapped word
sortwrd : to store the sorted word
Member functions/methods:
SwapSort( ) : default constructor to initialize data members
with legal initial values
void readword( ) : to accept a word in UPPER CASE
void swapchar( ) : to interchange/swap the first and last characters
of the word in ‘wrd’ and stores the new word
in ‘swapwrd’
void sortword( ) : sorts the characters of the original word in
alphabetical order and stores it in ‘sortwrd’
void display( ) : displays the original word, swapped word and
the sorted word
Specify the class SwapSort, giving the details of the constructor( ), void readword( ),
void swapchar( ), void sortword( ) and void display( ). Define the main( ) function to
create an object and call the functions accordingly to enable the task.
SECTION – C
Answer any two questions.
Each program should be written in such a way that it clearly depicts the logic of the problem
stepwise.
This can be achieved by using comments in the program and mnemonic names or pseudo codes for
algorithms. The programs must be written in Java and the algorithms must be written in general /
standard form, wherever required / specified.
(Flowcharts are not required.)
Question 10
A super class Product has been defined to store the details of a product sold by a
wholesaler to a retailer. Define a sub class Sales to compute the total amount paid by the
retailer with or without fine along with service tax.
[5]
-------------------------------------------------------------------------------------------------------------------------------
7
1217-868A Turn over
Some of the members of both the classes are given below:
Class name : Product
Data member/instance variable:
name : stores the name of the product
code : integer to store the product code
amount : stores the total sale amount of the product (in
decimals)
Member functions/methods:
Product(String n, int c, double p) : parameterized constructor to assign data
members name=n, code=c and amount = p
void show( ) : displays the details of the data members
Class name: Sales
Data member/instance variable:
day : stores number of days taken to pay the sale
amount
tax : to store the service tax (in decimals)
totamt : to store the total amount (in decimals)
Member functions/methods:
Sales(…) : parameterized constructor to assign values to
data members of both the classes
void compute( ) : calculates the service tax @ 12·4% of the actual
sale amount
calculates the fine @ 2·5% of the actual sale
amount only if the amount paid by the retailer to
the wholesaler exceeds 30 days
calculates the total amount paid by the retailer as
(actual sale amount + service tax + fine)
void show( ) : displays the data members of super class and the
total amount
Assume that the super class Product has been defined. Using the concept of inheritance,
specify the class Sales giving the details of the constructor(…),void compute( ) and
void show( ).
The super class, main function and algorithm need NOT be written.
-------------------------------------------------------------------------------------------------------------------------------
8
1217-868A
Question 11
Queue is an entity which can hold a maximum of 100 integers. The queue enables the
user to add integers from the rear and remove integers from the front.
Define a class Queue with the following details:
[5]
Class name : Queue
Data Members / instance
variables:
Que[ ] : array to hold the integer elements
size : stores the size of the array
front : to point the index of the front
rear : to point the index of the rear
Member functions:
Queue (int mm) constructor to initialize the data
size = mm, front = 0, rear = 0
void addele(int v ) : to add integer from the rear if possible
else display the message “Overflow”
int delele( ) : returns elements from front if present,
otherwise displays the message
“Underflow” and return -9999
void display ( ) : displays the array elements
Specify the class Queue giving details of ONLY the functions void addele(int) and
int delele( ). Assume that the other functions have been defined.
The main function and algorithm need NOT be written.
Question 12
(a) A linked list is formed from the objects of the class Node. The class structure of the
Node is given below:
class Node
{
int num;
Node next;
}
Write an Algorithm OR a Method to count the nodes that contain only odd integers
from an existing linked list and returns the count.
The method declaration is as follows:
int CountOdd( Node startPtr )
[2]
-------------------------------------------------------------------------------------------------------------------------------
9
1217-868A Turn over
(b) Answer the following questions from the diagram of a Binary Tree given below:
(i) Write the postorder traversal of the above tree structure. [1]
(ii) State the level numbers of the nodes N and R if the root is at 0 (zero) level. [1]
(iii) List the internal nodes of the right sub-tree. [1]
M
N G
W Y Z D
R
F

More Related Content

Similar to Computer Science Paper 1 (Theory) - 2017.pdf (20)

DOCX
703497334-ICSE-Class-9-Computer-Applications-Sample-Question-Papers.docx
vaanydev
 
PDF
Python Manuel-R2021.pdf
RamprakashSingaravel1
 
PDF
SE-IT JAVA LAB SYLLABUS
nikshaikh786
 
PDF
E7
lksoo
 
DOCX
B61301007 matlab documentation
Manchireddy Reddy
 
PDF
Advanced Web Technology ass.pdf
simenehanmut
 
PDF
ComputerScience-SQP.pdffhtu h kya hua hai ap ka school
ravita44554455
 
PDF
XII CS QUESTION BANK FOR BRIGHT STUDENTS CHAPTER WISE SET-II.pdf
kvfwteachers
 
PDF
class 12 computer science pdf of class e
rajadityaasingh22
 
PDF
Cs practical file
Shailendra Garg
 
DOC
Java programming lab assignments
rajni kaushal
 
PDF
Java Question-Bank-Class-8.pdf
Aditya Kumar
 
PPTX
Week_02_Lec_ Java Intro continueed..pptx
ibrahemtariq
 
PPTX
Using-Python-Libraries.9485146.powerpoint.pptx
UadAccount
 
PDF
CP Handout#9
trupti1976
 
PDF
Computer Science Sample Paper 2015
Poonam Chopra
 
PPT
sonam Kumari python.ppt
ssuserd64918
 
PPTX
C++ STL (quickest way to learn, even for absolute beginners).pptx
Abhishek Tirkey
 
PPTX
C++ STL (quickest way to learn, even for absolute beginners).pptx
GauravPandey43518
 
PPTX
Arrays 2d Arrays 2d Arrays 2d Arrrays 2d
LakshayBhardwaj39
 
703497334-ICSE-Class-9-Computer-Applications-Sample-Question-Papers.docx
vaanydev
 
Python Manuel-R2021.pdf
RamprakashSingaravel1
 
SE-IT JAVA LAB SYLLABUS
nikshaikh786
 
E7
lksoo
 
B61301007 matlab documentation
Manchireddy Reddy
 
Advanced Web Technology ass.pdf
simenehanmut
 
ComputerScience-SQP.pdffhtu h kya hua hai ap ka school
ravita44554455
 
XII CS QUESTION BANK FOR BRIGHT STUDENTS CHAPTER WISE SET-II.pdf
kvfwteachers
 
class 12 computer science pdf of class e
rajadityaasingh22
 
Cs practical file
Shailendra Garg
 
Java programming lab assignments
rajni kaushal
 
Java Question-Bank-Class-8.pdf
Aditya Kumar
 
Week_02_Lec_ Java Intro continueed..pptx
ibrahemtariq
 
Using-Python-Libraries.9485146.powerpoint.pptx
UadAccount
 
CP Handout#9
trupti1976
 
Computer Science Sample Paper 2015
Poonam Chopra
 
sonam Kumari python.ppt
ssuserd64918
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
Abhishek Tirkey
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
GauravPandey43518
 
Arrays 2d Arrays 2d Arrays 2d Arrrays 2d
LakshayBhardwaj39
 

Recently uploaded (20)

PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPTX
Gall bladder, Small intestine and Large intestine.pptx
rekhapositivity
 
PPTX
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
PDF
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PDF
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
DOCX
A summary of SPRING SILKWORMS by Mao Dun.docx
maryjosie1
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PPTX
How to Configure Lost Reasons in Odoo 18 CRM
Celine George
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PDF
Federal dollars withheld by district, charter, grant recipient
Mebane Rash
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
CHILD RIGHTS AND PROTECTION QUESTION BANK
Dr Raja Mohammed T
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Gall bladder, Small intestine and Large intestine.pptx
rekhapositivity
 
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
A summary of SPRING SILKWORMS by Mao Dun.docx
maryjosie1
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
How to Configure Lost Reasons in Odoo 18 CRM
Celine George
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
Federal dollars withheld by district, charter, grant recipient
Mebane Rash
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
CHILD RIGHTS AND PROTECTION QUESTION BANK
Dr Raja Mohammed T
 
Ad

Computer Science Paper 1 (Theory) - 2017.pdf

  • 1. --------------------------------------------------------------------------------------------------------------------- This Paper consists of 9 printed pages and 1 blank page. 1217-868 A Turn over © Copyright reserved. COMPUTER SCIENCE PAPER 1 (THEORY) (Maximum Marks: 70) (Time allowed: Three hours) (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time.) ------------------------------------------------------------------------------------------------------------------------------- Answer all questions in Part I (compulsory) and six questions from Part-II, choosing two questions from Section-A, two from Section-B and two from Section-C . All working, including rough work, should be done on the same sheet as the rest of the answer. The intended marks for questions or parts of questions are given in brackets [ ]. --------------------------------------------------------------------------------------------------------------------- PART I (20 Marks) Answer all questions. While answering questions in this Part, indicate briefly your working and reasoning, wherever required. Question 1 (a) State the law represented by the following proposition and prove it with the help of a truth table: P V P = P [1] (b) State the Principle of Duality. [1] (c) Find the complement of the following Boolean expression using De Morgan’s law: F(a,b,c) = (bʹ + c) + a [1] (d) Draw the logic diagram and truth table for a 2 input XNOR gate. [1] (e) If (~P => Q) then write its: [1] (i) Inverse (ii) Converse
  • 2. ------------------------------------------------------------------------------------------------------------------------------- 2 1217-868A Question 2 (a) What is an interface? How is it different from a class? [2] (b) Convert the following infix expression to postfix form: P * Q / R + (S + T) [2] (c) A matrix P[15][10] is stored with each element requiring 8 bytes of storage. If the base address at P[0][0] is 1400, determine the address at P[10][7] when the matrix is stored in Row Major Wise. [2] (d) (i) What is the worst case complexity of the following code segment: for (int x = 1; x <=a; x++) { statements; } for (int y = 1; y <=b; y++) { for (int z = 1; z <=c; z++) { statements; } } [2] (ii) How would the complexity change if all the three loops went to N instead of a, b and c? (e) Differentiate between a constructor and a method of a class. [2] Question 3 The following function magicfun( ) is a part of some class. What will the function magicfun( ) return, when the value of n=7 and n=10, respectively? Show the dry run/working: int magicfun( int n) { if ( n= = 0) return 0; else return magicfun(n/2) * 10 + (n % 2); } [5]
  • 3. ------------------------------------------------------------------------------------------------------------------------------- 3 1217-868A Turn over PART – II (50 Marks) Answer six questions in this part, choosing two questions from Section A, two from Section B and two from Section C. SECTION - A Answer any two questions. Question 4 (a) Given the Boolean function F(A, B, C, D) = Ʃ (2,3,4,5,6,7,8,10,11). (i) Reduce the above expression by using 4-variable Karnaugh map, showing the various groups (i.e. octal, quads and pairs). [4] (ii) Draw the logic gate diagram for the reduced expression. Assume that the variables and their complements are available as inputs. [1] (b) Given the Boolean function F(P, Q, R, S) = 𝝅(0,1,2,4,5,6,8,10). (i) Reduce the above expression by using 4-variable Karnaugh map, showing the various groups (i.e. octal, quads and pairs). [4] (ii) Draw the logic gate diagram for the reduced expression. Assume that the variables and their complements are available as inputs. [1] Question 5 (a) A school intends to select candidates for an Inter-School Essay Competition as per the criteria given below:  The student has participated in an earlier competition and is very creative. OR  The student is very creative and has excellent general awareness, but has not participated in any competition earlier. OR  The student has excellent general awareness and has won prize in an inter-house competition. The inputs are: INPUTS A participated in a competition earlier B is very creative C won prize in an inter-house competition D has excellent general awareness (In all the above cases 1 indicates yes and 0 indicates no). Output : X [1 indicates yes, 0 indicates no for all cases] Draw the truth table for the inputs and outputs given above and write the POS expression for X(A,B,C,D). [5]
  • 4. ------------------------------------------------------------------------------------------------------------------------------- 4 1217-868A (b) State the application of a Half Adder. Draw the truth table and circuit diagram for a Half Adder. [3] (c) Convert the following Boolean expression into its canonical POS form: F(A,B,C) = ( B + Cʹ) · (Aʹ + B) [2] Question 6 (a) What is a Multiplexer? How is it different from a decoder? Draw the circuit diagram for a 8:1 Multiplexer. [5] (b) Prove the Boolean expression using Boolean laws. Also, mention the law used at each step. F = (xʹ + z) + [ (yʹ + z) • (xʹ + y) ]ʹ = 1 [3] (c) Define maxterms and minterms. Find the maxterm and minterm when: P = 0, Q = 1, R = 1 and S = 0 [2] SECTION – B Answer any two questions. Each program should be written in such a way that it clearly depicts the logic of the problem. This can be achieved by using mnemonic names and comments in the program. (Flowcharts and Algorithms are not required.) The programs must be written in Java. Question 7 A class Palin has been defined to check whether a positive number is a Palindrome number or not. The number ‘N’ is palindrome if the original number and its reverse are same. Some of the members of the class are given below: [10] Class name : Palin Data members/instance variables: num : integer to store the number revnum : integer to store the reverse of the number Methods/Member functions: Palin( ) : constructor to initialize data members with legal initial values void accept( ) : to accept the number int reverse(int y) : reverses the parameterized argument ‘y’ and stores it in ‘revnum’ using recursive technique void check( ) : checks whether the number is a Palindrome by invoking the function reverse( ) and display the result with an appropriate message
  • 5. ------------------------------------------------------------------------------------------------------------------------------- 5 1217-868A Turn over Specify the class Palin giving the details of the constructor( ), void accept( ), int reverse( int ) and void check( ). Define the main( ) function to create an object and call the functions accordingly to enable the task. Question 8 A class Adder has been defined to add any two accepted time. Example: Time A - 6 hours 35 minutes Time B - 7 hours 45 minutes Their sum is - 14 hours 20 minutes ( where 60 minutes = 1 hour) The details of the members of the class are given below: [10] Class name : Adder Data member/instance variable: a[ ] : integer array to hold two elements (hours and minutes) Member functions/methods: Adder( ) : constructor to assign 0 to the array elements void readtime( ) : to enter the elements of the array void addtime( Adder X, Adder Y) : adds the time of the two parameterized objects X and Y and stores the sum in the current calling object void disptime( ) : displays the array elements with an appropriate message (i.e. hours = and minutes = ) Specify the class Adder giving details of the constructor( ), void readtime( ), void addtime(Adder, Adder) and void disptime( ). Define the main( ) function to create objects and call the functions accordingly to enable the task.
  • 6. ------------------------------------------------------------------------------------------------------------------------------- 6 1217-868A Question 9 A class SwapSort has been defined to perform string related operations on a word input. Some of the members of the class are as follows: [10] Class name : SwapSort Data members/instance variables: wrd : to store a word len : integer to store length of the word swapwrd : to store the swapped word sortwrd : to store the sorted word Member functions/methods: SwapSort( ) : default constructor to initialize data members with legal initial values void readword( ) : to accept a word in UPPER CASE void swapchar( ) : to interchange/swap the first and last characters of the word in ‘wrd’ and stores the new word in ‘swapwrd’ void sortword( ) : sorts the characters of the original word in alphabetical order and stores it in ‘sortwrd’ void display( ) : displays the original word, swapped word and the sorted word Specify the class SwapSort, giving the details of the constructor( ), void readword( ), void swapchar( ), void sortword( ) and void display( ). Define the main( ) function to create an object and call the functions accordingly to enable the task. SECTION – C Answer any two questions. Each program should be written in such a way that it clearly depicts the logic of the problem stepwise. This can be achieved by using comments in the program and mnemonic names or pseudo codes for algorithms. The programs must be written in Java and the algorithms must be written in general / standard form, wherever required / specified. (Flowcharts are not required.) Question 10 A super class Product has been defined to store the details of a product sold by a wholesaler to a retailer. Define a sub class Sales to compute the total amount paid by the retailer with or without fine along with service tax. [5]
  • 7. ------------------------------------------------------------------------------------------------------------------------------- 7 1217-868A Turn over Some of the members of both the classes are given below: Class name : Product Data member/instance variable: name : stores the name of the product code : integer to store the product code amount : stores the total sale amount of the product (in decimals) Member functions/methods: Product(String n, int c, double p) : parameterized constructor to assign data members name=n, code=c and amount = p void show( ) : displays the details of the data members Class name: Sales Data member/instance variable: day : stores number of days taken to pay the sale amount tax : to store the service tax (in decimals) totamt : to store the total amount (in decimals) Member functions/methods: Sales(…) : parameterized constructor to assign values to data members of both the classes void compute( ) : calculates the service tax @ 12·4% of the actual sale amount calculates the fine @ 2·5% of the actual sale amount only if the amount paid by the retailer to the wholesaler exceeds 30 days calculates the total amount paid by the retailer as (actual sale amount + service tax + fine) void show( ) : displays the data members of super class and the total amount Assume that the super class Product has been defined. Using the concept of inheritance, specify the class Sales giving the details of the constructor(…),void compute( ) and void show( ). The super class, main function and algorithm need NOT be written.
  • 8. ------------------------------------------------------------------------------------------------------------------------------- 8 1217-868A Question 11 Queue is an entity which can hold a maximum of 100 integers. The queue enables the user to add integers from the rear and remove integers from the front. Define a class Queue with the following details: [5] Class name : Queue Data Members / instance variables: Que[ ] : array to hold the integer elements size : stores the size of the array front : to point the index of the front rear : to point the index of the rear Member functions: Queue (int mm) constructor to initialize the data size = mm, front = 0, rear = 0 void addele(int v ) : to add integer from the rear if possible else display the message “Overflow” int delele( ) : returns elements from front if present, otherwise displays the message “Underflow” and return -9999 void display ( ) : displays the array elements Specify the class Queue giving details of ONLY the functions void addele(int) and int delele( ). Assume that the other functions have been defined. The main function and algorithm need NOT be written. Question 12 (a) A linked list is formed from the objects of the class Node. The class structure of the Node is given below: class Node { int num; Node next; } Write an Algorithm OR a Method to count the nodes that contain only odd integers from an existing linked list and returns the count. The method declaration is as follows: int CountOdd( Node startPtr ) [2]
  • 9. ------------------------------------------------------------------------------------------------------------------------------- 9 1217-868A Turn over (b) Answer the following questions from the diagram of a Binary Tree given below: (i) Write the postorder traversal of the above tree structure. [1] (ii) State the level numbers of the nodes N and R if the root is at 0 (zero) level. [1] (iii) List the internal nodes of the right sub-tree. [1] M N G W Y Z D R F