Formatting page ...
MOCK EXAMINATION DECEMBER 2019 Grade: 10 COMPUTER APPLICATION Duration: 2 Hours Date: 19.12.2019 Max. Marks: 100 [The time stated above is the time allowed for writing the examination. In addition, the 15 minutes will be given for reading the question paper.] All working, including rough work should be done on the same sheet as rest of the answer. The intended marks for questions or parts of questions are given in brackets. Section A Answer all questions For loop based output questions, show the dry run in a tabular form and for other output questions show the working. Question 1 a. Write one word answer for the following: (i) A method that converts a string to a primitive integer data type (ii) The default initial value of a boolean variable data type (iii) The keyword that makes the variable as a class variable (iv) The keyword that indicates that a method has no return type [2] b. What is the use of the this keyword? [2] c. Identify and name the following tokens: (i) public (ii) 'a' (iii) == (iv) { } [2] d. Why is a class known as a composite data type? [2] e. Differentiate between pure and impure functions. [2] Question 2 a. Write an expression in Java for the following arithmetic expression. [2] b. When there are multiple definitions with the same function name, what makes them different from each other? [2] Page 1 of 5 c. Consider the following code and answer the questions that follow: [2] public class academic { private int admno; private String name; private static count; public academic(int admno, String name) { this.admno=admno; this.name=name; ++count; } public static void main() { int a=1001; String b= ANITA ; academic ob=new academic(a,b); a=1010; String b= AJAY ; academic ob1=new academic(a,b); System.out.println(academic.count); } } (i) List the objects of class academic. (ii) List the class variables, Instance variables and local variables used in the program. (iii) Give the output d. Name two jump statements and their use. [2] e. Write the prototypes of any 2 overloaded functions in the String class [2] Question 3 a. Differentiate between static and non-static data members. [2] b. Differentiate between private and protected visibility modifiers. [2] c. What do you understand by data abstraction? Explain with an example. [2] d. Analyse the following program segment and determine how many times the loop will be executed and what will be the output of the program segment. [2] int k=1, i=2; while (++i<6) k*=I; System.out.println(k); Page 2 of 5 e.(i)Give the prototype of a function check which receives a character ch and an integer n and returns true or false. [1] (ii)Extract the second last character of a word stored in the variable wd. [1] Question 4 a. State two features of a constructor. [2] b. Create a class called Numwrd that has one integer instance variable called k, one String instance variable called St. Initialize the data members using: (i) default constructor (ii) parameterized constructor. [2] c. What is meant by a package? Name any two Java Application Programming Interface packages. [2] d. Give the output of the following code: String A= "26", B= "100" ; String D= A+B+ 200 int x= Integer.parseInt(A); int y= Integer.parseInt(B); int d=x+y; System.out.println( Result 1 = +D); System.out.println( Result 2 = +d); f. What is the use of the ternary operator? Give its syntax and give an example. [2] [2] Section B Answer any 4 Variable description and appropriate comments needs to be included Question 5 [15] Write a program to input a sentence, convert it to upper case and print the longest word and its length. If there is more than one word of the same length, then the word that is alphabetically greater must be displayed. Sample Input: India is my country Output: Longest Word : COUNTRY Length : 7 Sample Input : Sugar spice candy and salt Output: Longest Word : SUGAR Length : 5 Question 6 [15] Design a class RailwayTicket with the following description: Class name : RailwayTicket Instance variables/data members: String name : to store the name of the customer. Page 3 of 5 String coach long mobno int amt int totalamt : : : : to store the type of coach customer wants to travel. to store customer s mobile number. to store basic amount of ticket. to store the amount to be paid after updating the original amount. Methods: void accept() void update() : : to take input for name, coach, mobile number and amount. to update the amount as per the coach selected. Extra amount to be added as per the table given below: Type of coaches Amount First_AC 700 Second_AC 500 Third_AC 250 Sleeper None void display() : To display all details of a customer such as name, coach, total amount and mobile number. Write a main() method to create an object of the class and call the above methods. Question 7 [15] Write a program to initialize the seven Wonders of the World along with their locations in two different arrays. Search for a name of the country input by the user. If found, display the name of the country along with its Wonder, otherwise display Sorry Not Found! Seven wonders CHICHEN ITZA, CHRIST THE RDEEEMER, TAJMAHAL, GREAT WALL OF CHINA, MACHU PICCHU, PETRA, COLOSSEUM Locations MEXICO, BRAZIL, INDIA, CHINA, PERU, JORDAN, ITALY Example Country Name: INDIA Output: INDIA TAJMAHAL Country Name: USA Output: Sorry Not Found! Question 8 [15] Design a class to overload a function check() as follows: i) void check(String str, char ch) to find and print the frequency of a character in a string. Example : Input Output Str = success number of s present is = 3 ch = s ii) void check (String s1) to display only the vowels from string s1 , after converting it to lower case. Example : Input: S1= computer output: o u e Page 4 of 5 Question 9 [15] Write a program to accept the year of graduation from school as an integer value from the user. Using the Binary Search technique on the sorted array of integers given below, output the message Record exists if the value input is located in the array. If not, output the message Record does not exist . (1982, 1987, 1993. 1996, 1999, 2003, 2006, 2007, 2009, 2010) Sample Input & Output: Enter year of graduation: 2007 Record exists Enter year of graduation: 1900 Record does not exist Question 10 Using switch statement, write a menu driven program for the following: i) To find and display the sum of the series given below: S = x1 x2 + x3 x4 + x5 x20 (where x=2) ii) To display the following series: 1 11 111 1111 11111 For an incorrect option, an appropriate error message should be displayed. Display the menu repeatedly, until the user chooses exit. Sample output 1 Menu 1. Sum of series 2. Display Series 3. Exit Enter your choice: 1 Sum = -699050.0 Sample output 2 Menu 1. Sum of series 2. Display Series 3. Exit Enter your choice: 2 1 11 111 1111 11111 Page 5 of 5 [15]
|