Formatting page ...
. .. ,- LA MARTINI ERE FOR soYS, KOLKAT A REHEARSA L EXAMINATION 2023-24 SUBJECT: COMPUTER APPLICATIO N "" S CLASS:X Time: 2 hours + 15 mlns. Reading time Full marks: 100 Answer all questions from Sectic,n A and any 4 out of 6 questions from Section B. Do not copy any question,s. The Intended marks for the questions are given In brackets. SECTION A Answer All Questions (40 marks) [20] th Choose the correct answers to the questions from the given options (Do not copy e , questions, write the correct answers/option only) QUESTION 1: 1. When we pass an array to a method, the method receives a. The length of the array b. A reference of the array c. A copy of the array d. Each of the elements of the array Ii. Which principle of OOP Is used for hiding unnecessary details from the external world: Encapsulation b. Inheritance C. Abstraction d. Polymorphism a. m. The range of ASCII values of the lower case letters lies in the range of a. 66 to 92 b. 65 to 90 c. 97 to 121 , d. 97 to 122 Iv. What will be the result of x%y, if the value of x=S an~ y=-2 , a. 1 b. 0 c. 1.0 . . . . . rt ., IA II MAI 1 d. -1 sed within a Pal Of A sequence of statements enc1O r curly brackets Is known as: v. a. b. . c. d. Null statement Vold statement compound statement Empty statement vi. Which of the following Is an empty loop a. for(l=O;l<6;l++); b. whlle(l<S) l++; c. do{ l++; } while(l<6); d. none of the above v. II What will be the output of the following Java statement System.out.prlntln("HE".compareTo("HELL~")); a. -3 b. 2 c. 5 d. -2 viii. What will be the output of the following Java statements int arr[][]={{l,2,9},{1,2,3},{1,6,1}}; System .out.prlntln(arr[1].length); a. The following code will produce an error b. 3 c. 2 d. 0 Ix. What Is the prerequisite for performing binary search on an array a. The array must contain odd number of elements b. The array must contain even number of elements c. The element to be searched should either be placed in the beginning or at the end of the . array d. The array must be sorted x. ~at will be the outpu t of the following code Ystem.out.println("DEDICATED".indexOf('D',2)); a. 0 b. 7 c. 2 d. -1 xi. Name the package of h" w ch th~ String class is a part of a. java.math 'b. java.lang C. java.util d. java.io xii. What is the use of t~e following escape sequence \n: a. Inserts a tab b. Inserts a null characterc. Inserts ~he character n d. Inserts a newline xiii. Name the feature of Java depicted in the above picture a. Polymorphism b. Encapsulation c. Abstraction d. Parameterized Constructor xiv. Assertion (A) : Java programs can run on any platform that has the corresponding NM installed in It Reason (R}: Java is a platform dependent programming language a. Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertion (A) b. Both Assertion (A) and Reason (R) are true and Reason {R) is not a correct explanation of Assertion (A) c. Assertion (A) ~s false and Reason (R) is true 1o-comp. app. 3/8 (LMB) d. Assertion (A) is true and Reason (R) is false Assertfon(A): Static data members do not require to be Invoked by an object Reason (R): Only one copy of the 5tatic variable Is created and Is xv. shared by all the objects of the class. a. Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertfon (A). b. Both Assertion (A) and Reason (R) are true and Reason (R) ls not a correct explanation of Assertion (A) c. Assertion (A) \s false and Reason (R) is true d. Assertion (A} is true and Reason (R) ls false xvi. a. b. c. d. What will be the output of the following Java code System.out.println("DEDICATED" .endsWith('D')); false The above statement will generate a logical error true The above statement will generate a syntax error xvii. What will the value of k, if a= 5 and b=7; k=--a -2 -~K- * b++ + b%-a +a a. 43 b. 37 c. 41 d. 44 xviii. Read the following text and choose the correct answer: Mr. Srinivasan, a renowned programmer wants to use a proper ty where in he intend s to access the data members of one class from anothe r class. Which proper ty of an OOP does he intend to use? a. b. c. ,. d. xix. Constructor Overloading Metho d overloading Encapsulation Inheritance Which of the followi ng components is contai ned in the BlueJ enviro nment a. Code Editor b. Debugger 10-comp. app. -4/8 (LMB) c. Terminal d. All of the above xx. Which of th t e ollowing is a relational operator: a. == b. I c. && d. + QUESTION 2: i. Write the Java statement for the t II . 0 owmg expression +Y '1ax ii. iii. (2) Evaluate the expression when the I va ue of k=S k -= --k + k++ -k {2) The following code h Id d s ou pnnt the letters A to z in Uppercase. However h t e co e has some errors. Fix the code so that it compiles and execu tes correctly. [i] for(int i=GS;i<=87;i++) { char ch=i; System .out.println(ch); } iv. V. State any 2 keywords used within the switch block [21 Predict the output of the following code segment String str="COMPUTER"; String strl="PROGRAM"; String str2=str.substring(2, 7)+1nteger.toString(strl.index Of(' r' ,1)); System.out.println(str2); vi. How many times will the loop execute and what will be int k=S; int i=-1; while(i++<9) { k+=i++; } System.out.println(k); 10-comp. app. -5/8 {LMB) the output [2] vu. consider the two arraVS [2) Int a() {i~3,4,S }; Int b() {St4,3,2,1}; what will be the outpu t If the follow1n st g atements are executed? d((lnt)Math.sqrt(a(l]) + M double m Math.roun . ath.sqrt(b[l)) Math.mln(a[3),b(2])); svstem.out.println(m), explicit Initialization h When there Is no ' w at are the default values set for var\ab\es In the following cases? \2\ vm. a. boolean variable b. character variable " State one point of difference in th e use of the statements break and System. Exit (0). {21 ix. . Ramesh tries to execute t~e foll~wing Program segment to find out the area of a x. circle. However the output rs obtained is incorrect. How the program can be modified to get the correct answer? Also state the type of error made by Ramesh. [2] double radius=S.9; double pi=3.14; int area= pi*Math:pow(radius,2}; System.out.println(area); . SECTION B (Answ_er any four questions from this Section.) Each program should be written using variable description I mnemonic codes so that the logic of the program is clearly depicted. ~STION 3: {15} An electricity board of a state has revised its tariff as per the following criteria. Design a class ElectricTariff with the following specifications: Class name: ElectricTariff . Member variables: name -to store the name of the customer units - to store the units consumed 10-comp. app. -6/8 (LMB) amount - the final amount to be paid by the customer Member functions ElectricTariff() - default constructor to initialize the member variables with default values void accept() - to accept the name and the number of units consumed void calculate - to calculate the amount to be paid as per the following criteria I Number of units consumed First 100 units Amount to be pald(ln Rs) 100 0.5 per unit 1.5 per unit Next 100 units Next 100 units Next 100 units Above 400 units 2 per unit 2.5 per unit H~wev~r a GST of 7.5% has to be added to the final bill. void display() - displays the name, units consumed and the amount to be paid by the customer Write a main function to create an object of the class and call the above functions QUESTION 4. [15) Write a program to accept the year of. world cup cricket as an integer value from the user. Using the Binary Search technique on the sorted array of integers given below, output the name of the winning team if the value input is located in the array. If not, output the message "Record does not .exist''. { 2023 I 2019 I 2015 I 2011, 2007 I 2003 I 1999 I 1996 I 1992 I 1987 I 1983 I 1979 I 1975} {"Australia", "England"," Australia", "India"," Australia"," Australia"," Australia", "Sri Lanka", "Pakistan"," Australia", "India ", "West Indies" , "West Indies"} ~TIONS: [1S) Write a menu driven program using switch case to: 1). Input a String in uppercase and display the first letter of every word. 2). Input a word, convert to uppercase and form a new string to shift all the consonants of the word at the beginning followed by the vowels. Print the formed string. (e.g., APPLE become~~) PPLAE. for an incorrect choice, display an appropriate message. 10-comp. app~ 7/ 8 (LMB) .-. Ji'ES TION 6: r (15) Design a class to overload the method print as follows void prlnt(Strlng a): to display th e following pattern using nested loop e.g. If a="COMPUTER" prints I COMPUTER t' {,.t I \_ l 1'.,l ) OMPUTER MPUTER PUTER UTER TER ER R void prlnt(lnt n) to check if the number Is a Sapphire number or not . A Sapphire number is a number which is 1 less than the cube of any number. For example 7, 26, 999 are Sapphire numbers. Display a suitable messa ge accordingly. I ~ST ION 7: n . L< (15} I Write a program to accept the names of 10 cities in an array. Sort the names in alphabetical order. Display the sorted arra'y. rSTI ON8 : [151 Design a class to accept elements into a 4X4 array and check wheth er it is a sparse matrix or not. A sparse matrix is a matrix in which most of the elements are zero. 0 0 3 0 0 0 0 8 1 0 3 0 0. o 7 0 4X4'Ma trlx Sparse Matrix 10-comp. app. -8/8 (LMB)
|