Formatting page ...
NIRAJ PUBLIC SCHOOL PREFINAL I NOV - 2020-21 COMPUTER APPLICATIONS CLASS: 10 TIME: 2 hrs. MARKS: 100 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 only. Answer 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 the questions QUESTION NO 1:- a) i)What is the difference between int and Integer. ii) Write the java expression for + b) What will be the output double a=10.0; double b=5.5; a=a+ a++ +--a+ --a + b++; System.out.println(a); System.out.println(b); c) State the output of the following program segment: int i=1; int s[ ]={2, 4, 6, 7, 8, 9, 10}; while(i<s.length) { System.out.println(s[i]+1); if(i< s.length-3) s[i+1]++; i++; } d) Differentiate between static and non static data members. e) Differentiate between compareTo( ) and equals( ). QUESTION NO 2:- (2) (2) (2) (2) (2) a) How many times will the following loop execute? What value will be returned? (2) int x=2, y=50; while(x<=10) { ++x; y =x++; } return y; b) Write the advantages of exception handling. (2) c) Write a java statement to display last 4 characters of String str . (2) d) Write the purpose of the following in Java: (2) i) import ii) return e) Write the difference between procedure oriented programming and object oriented programming. (2) QUESTION NO 3:- a) i) Rewrite the following code using while loop. int a,b; for (a=2,b=4; a<=10,a++,b++) System.out.println(a); System.out.println(b); b) c) d) e) f) ii) State number of iterations for the following loop: int a=10, x=7; while( a % x >=1) { a++; x+=2; } Write the difference between parameters and arguments. i) What are overloaded constructors? ii) What is an exception? Write the advantages of arrays. What will be the output: int a=5; for(int i=1; i<=2; i++) { a*= a++ - 15/a++; } System.out.println("value of a="+ a); Write the output: (2) (2) (2) (2) (2) System.out.println( Math.pow( Math.round(4.25), Math.sqrt(Math.floor(9.785)))); System.out.println( Math.max(Math.round(5.8), Math.pow(3,2))); g) i)What are identifiers? Give an example. ii) What is the use of the keyword this ? h) Rewrite the following if-else using ternary operator: if(x>y && x>z) var=x; else if(y>z) var=y; else var=z; i) Write the difference between call by value and call by reference. j) i) Define abstraction. ii) Write the range of values for the primitive data type short . (2) (2) (2) (2) SECTION B (60 Marks) Attempt any four questions from this Section. Each question carries 15 marks. The answers in this section should consist of the programs in either BlueJ environment or any program environment with Java as the base. Each program should be written using Variable descriptions/Mnemonic codes so that the logic of the program is clearly depicted. QUESTION NO 4:- Define a class Employee described as below Data members: Name, basicSalary,da,ta,pf,grossSalary,incomeTax Member methods: Employee() : Default constructor Accept() : To accept name and basicsalary Calc() : To calculate the Gross Salary for the month. Basic Salary DA TA >=20000 50% 12% <20000 and 51% 11% >=10000 <10000 52% 10% GrossSalary=(basicSalary+da+ta)-pf (15) PF 10% 8% 7% Compute() :To compute the annual income Tax as per the following table. Income Slab Annual Income Up to Rs. 2,50,000 Annual Income from 2,50,001 to Rs. 5,00,000 Annual Income from 5,00,001 to Rs. 10,00,000 Annual Income more than Rs. 10,00,000 Tax Rate No Tax 10% 20% 30% Display() : To display name, basic salary, gross salary and income tax in a tabular form. Write main() method to create object of the class and call the above member methods. QUESTION NO 5:- (15) 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*digit1 + 2*digit2 + 3*digit3 + 4*digit4 + 5*digit5 + 6*digit6 + 7*digit7 + 8*digit8 + 9*digit9 + 10*digit10 is divisible by 11. Example: For an ISBN 1401601499 Sum=1*1 + 2*4 + 0*0 + 4*1 + 5*6 + 6*0 + 7*1 + 8*4 + 9*9 + 10*9 = 253 which is divisible by 11. Write a program to: (i) input the ISBN code as a 10-digit number (ii) If the ISBN is not a 10-digit number, 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 . QUESTION NO 6:- Write the given overloaded methods: (15) a) 5 4 3 2 1 4321 321 21 1 b) c) ! + ! + ! + ! d) main() QUESTION NO 7:- (15) Write a program to input 20 important cities with their STD codes in two different arrays. The program displays the output as per the user s choice. 1. If the user enters STD code then it displays the corresponding city. 2. If the user enters name of city then it displays the STD code. If STD code or city is not found display appropriate error message. QUESTION NO 8:- (15) Write a menu driven program (using Scanner class functions) to accept a number and check if it is an Automorphic number or a neon number based on the choice input by the user. Automorphic number is a number which is present in the last digit(s) of its square. E.g. 25 252=625 25 is present as the last digits of its square. Neon number is a number where the sum of digits of square of the number is equal to the number. E.g. 9 92=81 8+1=9 For an incorrect choice, appropriate error message should be displayed. QUESTION NO 9:- Write a class with the following functions: i) ii) (15) Write a function to accept 3 integers as parameters and print them in descending order. Write a function to accept a number as a parameter and check if is a perfect number or not. Perfect Number: A number is said to be a perfect number if sum of its factors excluding the number is equal to the accepted number. Ex:- 6 Factors of 6= 1, 2, 3, 6 Sum of the factors excluding the number= 1+2+3=6
|