Formatting page ...
I The Bishop's Co-Ed School, Kalyanl Nagar. Pvoe First Jermlnal Examination (2024-2025) Computer Applications Total' Marks: 100 Minutes Time: 2 hours 15 Writing Time: Reading Date: 4-09-24 An.swe,s to this Paper must be written on the paper provided separately. You will not be allowed to write during the f!,st 15 minutes. This time Is to be spent In reading the question paper. The time given at the head ofthis Paper Is the time allowed for writing the answe,s. Class~O This paper is divided Into two sections. Attempt all questions from Section A and any four questions from s :tlon B The intended marks for questions or parts ofquestions are given In the brackets [ ]. I SECTION A {Attempt all questions from this Section) Question 1 [20] Choose the correct answers to the questions from the given options. (Do not copy the questions, write the correct answers only.) I. A loop within another loop Is called as. a. Double loop. b. Embedded loop. c. Circular loop. d. Nested loop. Ii. iii. iv. v. b vi. i Name the above structure. a. One dimensional array. b. Two-dimensional array with four rows and five columns. c. 3-dimensional array. d. Two-dimensional array with five rows and four columns. The size of' \t Is: d. 16 bytes c. 8 bytes b. 4 bytes a. 2 bytes : Is function impure an In used s parameter The type of d. char c. Reference type b. float a. int The statement used to find the total number of Integers present in the array int arr[] is: d. len(arr) c. length.arr[] b. arr.length() a. arr.length Consider the following program segment In which the statements are jumbled, choose the correct order of statements to swap two varlables using the third variable. void swap(int a, int b) { a= b; b = t; int t = O; j (Line 1) (Line 2) {Line 3) (Line 4) t = a; Line (1) (2) (3) (4) Line (3) (4) (1) (2) Line (1) (3) (4) {2) Line (2) {1) (4) (3) Assertion(A):An argument is a value that is passed to a method when it is called. Reason(R): Variables which are declared in a method prototype to receive values are called actual parameters. a. b. c. d. vii. 1 f r ' I' viii. ix. x. xi. / / 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) is true and Reason (R) is false d. Assertion (A) is false and Reason (R) Is true Which of the following is true for polymorphism? a. Use the same name for different purposes. b. Use the same operation for different functions. c. It is not a principle of OOPS. d. It uses reusability feature. Which of the following is not true with regards to a switch statement? a. checks for an equality between the input and the case labels . b. break is used to exit from the switch block c. supports floating point constants as case labels. d. case labels are unique. State the output for the given statement Math.sqrt(Math.max(9,16)); d. 9.0 c. 4 b. 4.0 a. 5.0 Consider the array given below: char chO={'S','E', V','E', 'N'}; Write the output of the following statements: System.out.println(ch(l]+ch[2]); b. EV a. S V xii. xiii. xiv. d. 155 c. 69 86 A loop which does not repeat the execution of any statement, but keeps the control engaged for sometimes until the iterations are completed is called? c. Null loop. d. Infinite loop. a. Endless loop. b. User controlled loop. the correct statement to initialize is Which elements. 20 has array A single dimensional the last element to 55 ? d. M [ 19 J = 55 c. M [ 21 ] = 55 a. M [ 18 ] = 55 b. M [ 20 ] = 55 integer? an only return would methods mathematical following Which of the a. Math.ceil(x) xv. xvi. xvii. b. Math.sqrt(x) c. Math.ffoor{x) The C0tTeCt statement to create an object Tavota ex the dass Car. d. Math.round(x) a. car toyota =new car ( ); b. Toyota c.ar = new Toyota ( ); c. c.arToyota = new c.ar ( ); d. Toyota car = new car ( ); Which unit of a dass gets called when the object of the dass is created? a. Main method b. User-defined Method c. Constructor d. sutx:lass Consider the following program segment and answer the question below: class calculate { int a; double b; calculate() { a=O; b=0.0; } calculate(int x, double y) { a=x; b=y; } Name the typed mnsb'udDls used in the a1Joye JIOQlan srvne,t? a. Defaft ConslruclDr, Non-Pa-anN!tlised ConslruclDr. b. Paramelaised ConslruclDr, Non-Pararnebtse ConsbuclDr. C. Non-Pararnelats ConslruclDr, Pcnmebised Ccnilrucmr. d. Defaut ConslruclDr, Paaa,N!tlised ConslruclDr. xviii. To execute a loop 10 times, which-~ the following is correct? a. for (int 1=12;1<=31;1+=2) b. for (int 1=12;1<=30;1+=3) c. for (int 1=12;1<30;i++) d. for(int i=12;i<=31;1+ ) . .- I' xix. xx. Name the type of error if any in the following statement: System.out.print(JAVA); d.Syntax c. Runtime b. No error a. Logical can a non-static method be accessed in a static method without the use of the object? a. Yes b. No c. Maybe d. Yes if it has a return type. Question 2 , i. Write the method prototype for the method compute which accepts three integer [2] arguments and returns true/false. ii. iii. State the difference between Binary Search and Linear Search Evaluate the expression when the value of m= 5; m= m - - + ++m + m++ - m What is data hiding? When there is no explicit initialization, what are the default values set for variables in the following cases? a. Double variable b. Character variable Y [] = {2,4,6}; int X [] = {1,3,5,7,9}; Place all the elements of X array and Y array in the array Z one after the other. a. Write the index position of the first and last element of Array Z. b. What will be the size of the array Z? Name two jump statements. Explain any one. Rewrite the following snippet using while loop instead of for statement. iv. "' v. ' vi. vii. viii. [2] [2] [2] [2] [2] [2] [2] int x=l; for(int i = l;i<=6;i++) { x= i*2; Ix. x. . ' Consider the following two-dimensional array answer the questions below. Int p [ ][] {{2,3,4}, {5,6,7}, {8,9,10}}; a. What Is the order of the array? b. What Is the value of p[2][1] + p[1][2] And the error in the following snippet. Write the correct statement. static sum ( ) = [21 [2] { int x:y; x=S; y =+5; system.out.println{x+ "+y); } SECTIONS (Answer any four questions from this Section.} The answers in this section should consist ofthe programs in any other BlueJ environment or any program environment with Java as the base. Row charts and algorithms are not required. Questlon3 Define a dass called Smartshop with the following specifications: Member variables: String name: name of the item purchased double price: Price of the item purchased Member methods: Smart:shop(Sbing n, Int p): to initialize the data members void calculate(): To calculate the net amount to be paid by a customer, based on the 3 tI 1 ~ /, ~ l l ' ~ ~ ~I I / following criteria: Discount 5.0% 7.5 % 10.0% 15.0% Price 1000- 25000 25001 - 57000 57001 - 100000 More than 100000 void display(): To display the name of the item and the net amount to be paid. Write the main method to create an object and call the above methods Question 4 Define a class to overload a method named display() as follows : void display ()- to display the following pattern using nested for loop: 54321 5432 543 54 5 [15] I - to display the su void display (int void display ( uble a, double b, do / Question 5 of all factors of n. ) - to display the value of p where p= m * n m= a+b/2 n = a+b+c [15] Write a Java program to accept 10 decimal numbers in a single dimensional array. Also enter a decimal number to be searched. By using Binary Search technique, check whether or not the number is present in the array. If the number is present, then display the message "Search successful" otherwise display "Search unsuccessful". [151 Question 6 Create a function prime (int n) that returns true if the number is a prime number, false, otherwise. Write a Java program to input a number and check if it is an EMIRP number or not, using the function prime (). (Hint: A number is called an EMIRP number if we get another prime number on reversing the number itself.) Example: 13 is an EMIRP number as 13 and 31 are prime numbers [15] Question 7 Define a Java class to accept values into array of order of 4X5. Display the sum of each column. Sample Input: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Output sum of column 1 =1+ 6+11+16=34 sum of column 2 = 2+7+12+17=38 sum of column 3= 3+8+ 13+ 18=42 sum of column 4= 4+9+14+19=46 sum of column 5= 5+10+15+20=50 [ 15] Question 8 ~ Write a Java program to input 10 (one-digit, two-digit or three-digit)numbers into an integer array. Display the count of one-digit numbers , two-digit numbers and threedigit numbers present in it, else print an appropriate message. For example, if array contains '' I..-~ ... l Enter \ 10 1 ~ nts in the array '" ,o ,, , ln, l.id ,, Inpu,: j:: l~ , }count of one-d1Q1t nu~bera 7 !Count o~ two-dig~t nu~berc jcount o~ three-digit nu~b r , I ***************** 4 I
|