Formatting page ...
FIRST PRELIMINARY EXAMINATION 2017 COMPUTER APPLICATIONS Class: X Marks: 100 Time: 2 Hrs. Date: 05/12/2017 Answer 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 answers. This Paper is divided into two Sections. Attempt all question from Section A and four question from Section B. The intended marks for questions or parts of questions are given in brackets [ ]. This paper consists of 4 printed pages. SECTION A (40 MARKS) (All questions are compulsory) Question 1. a) b) What do you mean by encapsulation? [2] State the output of the following: [4] i. int x = 13 , y = 5; System.out.println(x++ + x + -- y); ii. double b = -25.6; double a = Math.rint(Math.abs(b)); System.out.println( a= +a); c) Rewrite the given statement using ternary operator. [2] if (a > b) p = a-b else if(a< b) p = b-a else p = 0; d) Explain the keyword static giving example. [2] Explain the concept of wrapper class in Java. Give names of two wrapper [2] Question 2. a) classes used in Java. b) Write Java statements for the following: i. 5a + b(x+y) 5 ii. To declare a single subscripted variable X to store 20 integers. (1) [2] c) What is call by value and call by reference? [2] d) Read following code and answer the given questions: [4] int a[ ] = {2,5,3,7,8}; a[1] = a[2]; a[3] = a[4]; a[4]=a[1]+a[3]; for(int i = 0 ; i < 5; i++) System.out.print(a[i] + , ); i. What is the output of the above code? ii. How many bytes will the above array a[ ] occupy? Question 3. a) Read the following code and answer the given questions(show working). [4] int n =10; while ( n !=1) { if (n% 2 ==0) n = n /2; else n = (3*n) + 1; }System.out.println(n); i. What is the output of the following code? ii. How many times does the loop get executed? b) Give prototype of a function search which receives a sentence sent and word [2] wrd and returns 1 or 0. c) What is expression? What do you mean by mixed expression? [2] d) Name the following keyword that: [2] i. Distinguishes instance variable and class variable. ii. Informs that an error has occurred in an input/output operation. e) Differentiate between Formal ad Actual parameter. [2] f) What do you mean by Exception in Java? How are they handled in Java? [2] g) What do you mean by polymorphism? How is it implemented in Java? [2] h) What is class? How are objects related to class? [2] i) Explain that class is composite data type. [2] (2) SECTION B (60 MARKS) (Attempt any four questions) Question 4. Create a class Circle to find area and circumference of a circle using formula [15] Area = r 2 and Circumference = 2 r. The class has following data members and member functions. Data Members : R : float variable to store radius of the circle PI : float pi a constant to store value of Member functions: Circle ( ) : default constructor to assign value 3.14 to PI Circle ( float x): Parameterized constructor to assign value x to radius float findArea(): to calculate area of circle and return. float findCir() : to calculate circumference of a circle and return. Write a main function to input user choice to calculate area and circumference taking user choice and radius, it should also display the result returned. Note: Where area = 2 r 2 and circumference = 2 r. Question 5. A hotel has following special rates for stay depending on the number of days. Number of Days Rate First 3 days 350 /- per day For next 3 days 300 /- per day For next 3 days 275 /- per day Any day beyond 9 days 225 /- per day Write a program to input name and number of days stay for the N customer and calculate amount to be paid by each customer with their names. Display the output in the following format for each customer: S.No Name Amount payable 1 ------------ ------------ 2 ------------ ------------ ------------ ------------ (3) [15] Question 6. Write a program in java to input a sentence and reverse the sentence without [15] reversing the words. For example: if the input is quick brown fox jumps over a lazy dog than the output should be dog lazy a over jumps fox brown quick . Question 7. Define a class to accept N numbers from the user and store the same in an [15] integer array num[ ]. Print all the prime numbers from the array. Question 8. Using the switch statement, write a menu driven program to: [15] (i) Generate and display the following pattern: 1 24 135 2468 13579 (ii) To find the sum of the series given below: S = 1 + 1! + 2! + 3! + ..up to n terms (where x and n are to be input from the user. [Note: ! denotes the factorial of a number which is equal to product of the numbers starting from 1 till that number Example 5!= 1*2*3*4*5] Question 9. Write a program using a method void printOccurance(long num) to print the occurrence of the each digit present in the number (num). The output should be printed in the format given in the example output. Input : num = 434352 Output : Digit Frequency 2 1 3 2 4 2 5 1 ________________________ XXXXXX _________________________ (4) [15] (5)
|