Formatting page ...
The Shri Ram School, Moulsari Campus Mock Assessment, 2021-22 Class - XII COMPUTER SCIENCE PAPER 1 (THEORY) -----------------------------------------------------------------------------------------------Maximum Marks: 35 Time allowed: One and a half hour 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. The question paper contains 8 printed sides. -----------------------------------------------------------------------------------------------SECTION A -7 MARKS Question 1 (i) Which of these keywords is used by a class to use an interface defined previously? [1] a) import b) Import c) implement d) Implements Integrity Sensitivity Pursuit of Excellence MA/BC/XII/Computer Science/2021-22 Pride in One s Heritage 1 (ii) Which feature comes under compile time polymorphism? [1] a) Method overloading b) Constructor overloading c) Method overriding d) Both a and b (iii) int find(int m,int n) { return (m<n)?0 : 1+find(m-n,n); } With reference to the program code given above, what will the function find() return when the value of n=20 and m=65 ? [1] a) 4 b) 0 c) 5 d) 3 (iv) Write the statement in Java to extract the last word from the sentence STR and store in variable W after converting the extracted word in uppercase. [1] (v) State any two principles of Stack data structure. [1] (vi) What is the output of the statement given below? System.out.print(("SWITZERLAND".indexOf( M ) ) ); (ii) What is recursion? [1] [1] SECTION B - 8 MARKS Question 2 [2] Differentiate between linear and non-linear data structure. Integrity Sensitivity Pursuit of Excellence MA/BC/XII/Computer Science/2021-22 Pride in One s Heritage 2 Question 3 [2] Convert the following infix notation to postfix notation: A + (B * C / D E) / F Question 4 Answer the following questions on the diagram of a Binary Tree given below: (i) State the degree of the nodes C and H. Also, state the level of these nodes when the root is at level 0. [2] (ii) Write the post order traversal of the above tree structure. [1] (iii)Write the internal nodes of the above binary tree [1] SECTION C - 20 MARKS 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 5 [6] (i) Design a class Convert which converts the non-palindromic word into palindromic (Palindrome words are those which spell the same from either ends). Example: MOM, NAMAN etc. Integrity Sensitivity Pursuit of Excellence MA/BC/XII/Computer Science/2021-22 Pride in One s Heritage 3 The details of the members of the class are given below: Class name : Convert Data members/instance variables: wrd : stores a word len : to store the length of the word Methods/Member functions: Convert(String W) with W : a parameterized constructor to initialize wrd String revese( ) : returns the reverse of the word stored in wrd. boolean isPalindrome() otherwise return false. : returns true if wrd is a palindromic word void makePalindromic() : Convert the non-palindrome word into palindrome word by concatenating the word by its reverse (excluding the last character). If the word is already a palindrome word then display the word. Example: The reverse of the word HELP would be LEH (omitting the last alphabet) and by concatenating both, the new palindrome word is HELPLEH. Thus, the word HELP becomes HELPLEH. Specify the class Convert giving details of the constructor, String reverse(), boolean palindrome( ) and void makePalindromic( ). Define the main( ) function to create an object and call the functions accordingly to enable the task. OR (ii) Design a class Encode which encodes a sentence using Caesar Cipher technique. The details of the members of the class are given below: Class name : Encode Integrity Sensitivity Pursuit of Excellence MA/BC/XII/Computer Science/2021-22 Pride in One s Heritage 4 Data members/instance variables: str : stores a sentence newstr : stores the encoded sentence len : to store the length of str Methods/Member functions: Encode( ) : default constructor void readStr( ) : to accept the sentence void encodeStr ( ) : to encode the string str using Caesar cipher that replaces a letter with the letter 13 places after it in the alphabets, with the other characters remaining unchanged and stores it in newstr. If STR= YEAR-2022 Then newstr=LRNE-2022 void display( ) encoded word : displays the original word along with the Specify the class Encode giving details of the constructor, void readStr( ), void encodeStr( ) and void display( ). Define the main( ) function to create an object and call the functions accordingly to enable the task. Question 6 [6] Define a class with name Process that finds the smallest unique digit in a number. Class Name : Process Data Member: int Num; Member Functions: Process(int n) Num with n : a parameterized constructor to initialize Integrity Sensitivity Pursuit of Excellence MA/BC/XII/Computer Science/2021-22 Pride in One s Heritage 5 int count(int n, int d) recursive technique : to return the frequency of d in n using void smallestUniqueDigit() : to display the smallest digit of the number which is non-repeating(unique) Specify the class Number giving the details of the constructor( ), int count(), void smallestUniqueDigit(). Define the main() function to create an object and call the functions accordingly to enable the task. OR Define a class with name sumSeries that finds the sum of the series given below: xn/1+ an+2 /2+ an+4/3 + . an+18/10 Class Name : SumSeries Data Member: x,n sum Member Functions: SumSeries(int xx, int nn) instance variables :integers :double to store sum of the series : a parameterized constructor to initialize int power(int a, int b) recursive technique : to return a raised to the power b using void calcSum() variable sum. : to find the sum of the series and store in Specify the class Process giving the details of the constructor( ), int power(), void calcSum(). Define the main() function to create an object and call the functions accordingly to enable the task. Integrity Sensitivity Pursuit of Excellence MA/BC/XII/Computer Science/2021-22 Pride in One s Heritage 6 Question 7 [4] A super class with name Sale has been defined. Define another class 'Purchase' that inherits class 'Sale'. Some of the members of both the classes are given below: Class name :Sale Data members/ Instance variables: String title, author,publication double price Member methods: Sale( .) the data members : parameterized constructor to assign value to void display() name and price of a book : to display title, author name and publication Class name : Purchase Data members/ Instance variables: int noc int amount; Member methods: Purchase( ) : parameterized constructor to assign values to the data members of both the classes void calculate( ) : to find the amount by multiplying number of copies ordered and price (i.e., noc * price) void display() :to display the elements describes in base class along with the number of copies purchased and amount to be paid to the shopkeeper Assuming that the super class Sale has been defined. Using the concept of inheritance, specify the class Purcahse giving details of the constructor, void Integrity Sensitivity Pursuit of Excellence MA/BC/XII/Computer Science/2021-22 Pride in One s Heritage 7 calculate() and void display(). The super class, main() function and algorithm need not be written. Question 8 [4] In a computer game a vertical column and a pile of rings are displayed. The objective of the game is to pile up rings on the column till it is full. It can hold 10 rings at the most once the column is full the rings have to be removed from the top till the column is empty and then the game is over. Define the class ringGame with the following details : Class Name : RingGame Data Members : Ring[] : array to hold integers Max : integer to hold maximum capacity of array Upper : integer to the uppermost element Member functions : RingGame(int m) -1 : constructor to initialise Max to m and upper to void jumpIn(int r) : Adds a ring at the top of the column, if possible, otherwise display the message column is full, start removing rings void jumpOut() : remove the ring from the top, if column is not empty otherwise, output a message congratulations the game is over. Specify the class ring game giving details of the constructor and functions void jumpIn() and void jumpOut() Integrity Sensitivity Pursuit of Excellence MA/BC/XII/Computer Science/2021-22 Pride in One s Heritage 8
|