Formatting page ...
COMPUTER APPLICATIONS (Theory) (Two 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 from Section B. The intended marks for questions or parts of questions are given in brackets [ ]. SECTION A (40 Marks) Attempt all questions. Question 1. (a) What is meant by precedence of operators? [2] (b) What is a literal? [2] (c) State the Java concept that is implemented through: (i) a super class and a subclass (ii) the act of representing essential features without including background details. (d) Give a difference between a constructor and a method. (e) [2] What are the types of casting shown by the following examples? (i) [2] double x = 15.2; int y = (int) x; (ii) int x = 12; long y = x; [2] Question 2. (a) Name any two wrapper classes. [2] (b) What is the difference between a break statement and a continue statement when they occur in a loop? [2] T13 861 This Paper consists of 5 printed pages and 1 blank page. www.javaforschool.com Turn over (c) Write statements to show how finding the length of a character array and char[] differs from finding the length of a String object str. (d) Name the Java keyword that: (i) indicates that a method has no return type. (ii) (e) [2] stores the address of the currently - calling object. [2] What is an exception? [2] Question 3. (a) Write a Java statement to create an object mp4 of class digital. (b) [2] State the values stored in the variables str1 and str2 String s1 = "good"; String s2 = "world matters"; String str1 = s2.substring(5).replace('t', 'n'); String str2 = s1.concat(str1); [2] (c) What does a class encapsulate? [2] (d) Rewrite the following program segment using the if...else statement. comm =(sale>15000) ? sale*5/100 : 0; (e) [2] How many times will the following loop execute? What value will be returned? int x = 2, y = 50; do{ ++x; y - = x++; } while(x<=10); return y; (f) [2] What is the data type that the following library functions return? (i) isWhitespace(char ch) (ii) Math.random() [2] ut + ft (g) Write a Java expression for (h) If int n[ ] = {1, 2, 3, 5, 7, 9, 13, 16} what are the values of x and y? [2] x=Math.pow(n[4],n[2]); y=Math.sqrt(n[5]+[7]); [2] 2 T13 861 www.javaforschool.com (i) What is the final value of ctr when the iteration process given below, executes? int ctr=0; for(int i=1;i<=5;i++) for(int j=1;j<=5;j+=2) ++ctr; (j) [2] Name the methods of Scanner class that: (i) is used to input an integer data from the standard input stream. (ii) is used to input a String data from the standard input stream. [2] SECTION B (60 Marks) Attempt any four questions from this Section. The answers in this Section should consist of the Programs in either Blue J environment or any program environment with Java as the base. Each program should be written using Variable descriptions/Mnemonic Codes such that the logic of the program is clearly depicted. Flow-Charts and Algorithms are not required. Question 4. Define a class named FruitJuice with the following description: Instance variables/data members: int product_code - stores the product code number String flavour - stores the flavor of the juice (E.g. orange, apple, etc) String pack_type - stores the type of packaging (E.g. tetra-pack, PET bottle, etc) int pack_size - stores package size (E.g. 200ml, 400ml, etc) int product_price - stores the price of the product - Default constructor to initialize integer data members to 0 and String data members to "". Member Methods: (i) FriuitJuice() T13 861 3 www.javaforschool.com Turn over (ii) void input() - To input and store the product code, flavor, pack type, pack size and product price. (iii) void discount() - To reduce the product price by 10. (iv) void display() To display the product code, flavor, pack type, pack size and - product price. Question 5. The International Standard Book Number (ISBN) is a unique numeric book identifier which is printed on every book. The ISBN is based upon a 10-digit code. The ISBN is legal if: 1 x digit1 + 2 x digit2 + 3 x digit3 + 4 x digit4 + 5 x digit5 + 6 x digit6 + 7 x digit7 + 8 x digit8 + 9 x digit9 + 10 x digit10 is divisible by 11. Example: For an ISBN 1401601499 Sum=1 x 1 + 2 x 4 + 3 x 0 + 4 x 1 + 5 x 6 + 6 x 0 + 7 x 1 + 8 x 4 + 9 x 9 + 10 x 9 = 253 which is divisible by 11. Write a program to: (i) Input the ISBN code as a 10-digit integer. (ii) If the ISBN is not a 10-digit integer, output the message, "Illegal ISBN" and terminate the program. (iii) If the number is 10-digit, extract the digits of the number and compute the sum as explained above. If the sum is divisible by 11, output the message, "Legal ISBN". If the sum is not divisible by 11, output the message, "Illegal ISBN". [15] Question 6. Write a program that encodes a word into Piglatin. To translate word into a Piglatin word, convert the word into uppercase and then place the first vowel of the original word as the start of the new word along with the remaining alphabets. The alphabets present before the vowel being shifted towards the end followed by AY . Sample input (1) : London, Sample output (1) : ONDONLAY Sample input (2) : Olympics, Sample output (2) : OLYMPICSAY [15] 4 T13 861 www.javaforschool.com Question 7. Write a program to input 10 integer elements in an array and sort them in descending order using bubble sort technique. [15] Question 8. Design a class to overload a function series() as follows: (i) double series(double n) with one double argument and returns the sum of the series, sum = (ii) + + + + double series(double a, double n) with two double arguments and returns the sum of the series, sum = + + + + to n terms [15] Question 9. Using the switch statement, write a menu driven program: (i) To check and display whether a number input by the user is a composite number or not (A number is said to be a composite, if it has one or more than one factor excluding 1 and the number itself). Example: 4, 6, 8, 9 (ii) To find the smallest digit of an integer that is input: Sample input : 6524 Sample output : Smallest digit is 2 For an incorrect choice, an appropriate error message should be displayed. T13 861 5 www.javaforschool.com [15] Turn over
|