Formatting page ...
Preliminary Examination 2 2017-2018 COMPUTER APPLICATIONS Grade : X Date Max. Marks : // : 100 Time Allowed : 2 hours Answers to this Paper must be written on the paper provided separately. You will not be allowed to write during the first 15 minutes. This time is to be spent in reading the question paper. The time given at the head of this Paper is the time allowed for writing the answers. This paper is divided into two sections. Attempt all questions from Section A and any four questions in Section B. The intended marks for questions or parts of questions are given in brackets[ ]. SECTION A (Attempt all questions from this section) [40 Marks] Question1 [10] a) Name the following: i) Which unit of class is called when the object of class is called? ii) Name the keyword which causes the control to transfer back to method call. b) What do you understand by the keyword? Explain with an example. c) Strings are immutable. Explain. d) What do you mean by type casting? How is implicit conversion different from explicit conversion? e) List any two wrapper class functions of Character and explain any one with an example. Question 2 [10] a) Distinguish between == and .equals(). 1 b) Mention the packages containing the following methods. Also identify these methods as static or non-static methods. i) trim() ii) next() iii) read() iv) random() c) Write statements to show how finding the length of a character array c[] differs from finding the length of a String object str[2]. d) What is a compound statement? Give an example. e) Mention the output and the count of iterations of the loop given below: int y = 0, i=0; for(int x = 3; x<=5;x++){ int y = x * x; System.out.println(i++); if(y >= 12) continue; } System.out.println(y); Question3 [20] a) State one difference and one similarity between while and do-while loop. b) What is the difference between subscript and subscripted variable? c) What is the output of the following: String str1 = great ; String str2 = minds ; System.out.print(str1.substring(0,2).concat(str2.substring(1))); System.out.println((char)42+ WH + str1.substring(2).toUpperCase()); d) Explain actual parameters and formal parameters with an example. e) Give the output of the following program segment: double x = -2.9, y = -2.5; System.out.println(Math.min(Math.floor(x), y)); System.out.println(Math.max(Math.ceil(y), x)); f) What are the benefits of using a method in java? 2 g) Complete the blanks in the given code snippet using the clues given as the comments: Display() { no1 = _______; //Value according to the output : resut1 6039 result 2475 no2 = _______; //Value according to the output : resut1 6039 result 2475 void main() { Display pn = new Dispay(); no1+ = ___ ; //Value according to the output : resut1 6039 result 2475 no2 - = _____; //Value according to the output : resut1 6039 result 2475 System.out.print( result1 + no1 + no2 + ); System.out.println( result2 + (pn.no1*pn.no2));} h) Differentiate between static and non-static data members. i) Mention the output value of the variable n, and its representation in bits, for the expression: boolean n= book .equals( Book ); j) Evaluate the expression, if the value of the variables a = 3 and b=6. b += a++ * (a * b) - ++b; SECTION B (Attempt any four questions from this section) [60 Marks] Questions 4 [15] Write a program by accepting age and distance using BufferedReader to compute bus fare according to the following criteria: Age(in years) Below 5 Distance ( in Kms) Any distance Fare (in Rupees) Nil 5 to 15 Below 20 Rs. 5 From 20 to 100 Rs. 15 Above 100 Rs. 30 3 More than 15 upto 60 Above 60 Below 20 Rs. 10 From 20 to 100 Rs. 50 Above 100 Rs. 100 Below 20 Nil From 20 to 100 Rs. 25 Above 100 Rs. 70 Print the age, distance in kms and the bus fare in the following pattern: Age Distance(in Kms) Bus_Fare *** *****Km Rs.**** Question 5 [15] Define the class Number with a static variable N of integer type. Initialize the member variable to 0(zero) using default constructor and accept the number using the function readNum(). Also in readNum() function write a menu driven program for the following: 1) Invoke the function square( ) to print all the digits of N which are perfect square. 1 is a square number. 2) Invoke the function prime( ) to print all the prime digits of N. 1 is not a prime number. Question 6 [15] Write a program to input an integer array A[ ] of n size. Store all even integers of array A[ ] from left to right and all odd integers from right to left on another array B[ ]. Print both the arrays in two different lines in the below format. A[ ] = { 32, 35, 2, 45, 37, 22, 14, 19} B[ ] = {32, 2, 22, 14, 19, 37, 45, 35} Question 7 [15] Write a program to overload the following functions: void series(int n ) To generate the sries: 0, 3, 8, 15,24, ..to n terms(Value of n is to be an input by the user) 4 void series( ): To find the sum of the series: S=1/2 + 3/4 + 5/6 + .+19/20. Write a main method to call the above methods. Question 8 [15] Write a program to accept a number and check whether it is an Emirp number or not. An Emirp number is a number which is prime backwards and forwards. For Example: 13 is an Emirp number since 13 and 31 are both prime numbers. Question 9 Input a word using BufferedReader in uppercase and check for the position of the first occurring vowel and perform the following operation. i) Words that begin with a vowel are concatenated with Y . For example, EUROPE becomes EUROPEY. ii) Words that contain a vowel in between should have the first part from the position of the vowel till end, followed by the part of the string from beginning till position of the vowel and is concatenated by C . For example PROJECT becomes OJECTPRC. iii) Words which do not contain a vowel are concatenated with N . For example, SKY becomes SKYN. Design a class Rearrange using the description of the data members and member functions given below: Class name: Rearrange Data members Txt : to store a word Cxt : to store the rearranged word len: to store the length of the word Member functions Rearrange(): constructor to initialize the instance variables void readword(): to accept the word input in UPPERCASE void convert(): converts the word into its changed form and stores it in string Txt 5 void display(): displays the original and the changed word Specify the class Rearrange giving the details of the constructor(), void readword(), void convert() and void display(). Define a main function to create an object and call the function accordingly to enable the task. ***** 6
|