Formatting page ...
LOYOLA SCHOOL, BHUBANESWAR PRE JCSE EXAMINATION- JANU RY, 2024 COMPUTER APPLICATIONS Time : 2hrs. FM: 100 Answers to this paper must be wrilten on the paper provided separately. You will not beallowed 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. Atempt all questions from Section A and four questions from Section B. The intended marks for questions or parts of questions are given in brackets []. SECTIONA [40 Marks] (Attempt all questions from this section.) [1 x 20 = 20] Question 1 Choose the correct answers to the questions from the given options. (Donot copy the question, write the correct answers only.) () Name the feature of Java depicted in the adjoining picture. (c) Abstraction (a) Encapsulation (b) Inheritance (i) (i) iv (v) (d) Polymorphism Which of these is a logical operator? (a) == (b) = .(c) ! (d) I= Conditional operator is also known as: (b) Binary (a) Unary (c) Ternary (d) Assignment The number of bytes occupied by an integer array of 5 elements. -(c) 20 bytes (b) 10 bytes (a)5 bytes (d) 40 bytes The Scanner class method used to accept an integer value is: -(b) nextlnt() (c) next() (a)nextinteger() (d) nextLine() (vi) Assertion (A): Java is both compiled and interpreted. Reason (R): Java is an object-oriented 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 the correct explanation of Assertion (A). 1 (c) Assertion (A) is true and Reason (R) is false (d) Assertion (A) is false and Reason (R) is true (vii) The output of Math.rint(2.5) +Math.round(4.5) is: (a) 8.0 (c) 6.0 (b) 7.0 (d) 5.0 (vii) Name the type of erro, if any in the following statement: if(num < 0) System.out.println("Positive";: (a) logical (ix) (b) no error (c) runtime (d) syntax Java statement to access the first element of an array X is: (a) X[0] (x) (b) X[1] The output of "VWonderful".substring(0, 6) is: (a) Won (b)Wonder (c) X[2] (d) X(3] (c) Wonderful (d)on Which of the following is the wrapper class for the data type int? (a) int (b) int (c) Integer (xi) (d)parselnt Name the package that contains Scanner class: (xi) (a) java.lang "(b) java.util (c) java.io (d) java.awt (xii) Which of these is/are composite data type(s)? (a) Classes (xiv) (xv) (b) Arrays " (c) Both a and b Which of these data types is known as immutable? (a) Arrays (b) String (c) char Which symbol is used to terminate aJava statement? (a) Semicolon (b) Colon (c) Comma (xvi) A method which doesn't have areturn type (not even void)? (a) Pure (b) Impure (c) Constructor (d) int (d) float (d) Dot (d) Overloaded (xvi) The index in arrays always begin from: (a) 0 (b) 1 (c) 5 (xvii) What is the return type of compareTo(0) method of the String class? (a) boolean (b) int (c) String (xix) (d) 10 (d) double What will be the output for: System.out.println(Character.isLetterOrDigit('4); (a)true (b) false (c) 1 (d) 0 Lw) ASsertion (A): Two or more methods can share the same name if they differ in their method signatures. Reason (R): Method overloading implements polymorphism. (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 the 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 Question 2 (2 x 10 = 20] (i) Write a Java expression for /la- b| (i) Evaluate the expression whenthe value of int x =4; x *= ++x % 2 + X; (i)The following code segment should print"Well done!" if your attendance %(att) is 2 75 and your average score (score) > 60. However, the code has errors. Fix the code so that it compiles and runs correctly. double att = 95.0; double score = 70.0; if( att>= 75 | |score >= 60) System.out.printin("Needs attention !"); else System.out.printin("Well done !"); (iv) Chris executes the following program segment to find the square root using Math.pow() and the answer displayed is 1.0 irrespective of any non-zero values given. Name the error. How the program can be modified to get the correct answer? void solve(int num){ double root = Math.pow(num, 1/ 2); System.out.printin("Square root using Math.pow="+ root); } (v) How manytimes will the following loop execute? What willbe the output? int num=1241; while(num <= 0){ System.out.printin(num); num /= 10; (vi) Write the output of the following String methods: (a) "ROBOTICS".lastindexOf('O') (b) "ROBOTICS".substring(5).toLowerCase() 3 (vii) Write a Java statement to exit from the program. (vii) Predict the output of the following code snippet: int a = 5; int b= 6; System.out.println(a +b), System.out.println(a +'A'+ b); (ix) Give the output: booleanbl]=new boolean[5]; System.out.println(b[o]); System.out.println(b.length); (x) Give the output: System.out.printin(WMACHINE LEARNING\"); SECTIONB [60 Marks] (Answer any four questions from this section.) 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 description/mnemonic codes so that the logic of the program is clearly depicted. Flowcharts and algorithms are not required. avestion 3 [15] Define a class called Coursera with the following specifications: Class name: Coursera Member variables: String course Name: name of the course enrolled in double score: marks scored in the course char grade: Grade secured by the student Member methods: Void receive(): Accept the course hame and the marks scored using the Scanner class methods void find(): Finds the suitable grade according to the marks secured based on the following criteria: Marks Secured 90or above Grade A 70or above but below 90 B 40 or above but below 70 Below 40 D voiddisplay(): To display the course name, marks secured and the grade with suitable messages. Write the main() method to create an object and call the above methods. Question 4 [15] Define aclass to accept the marks of Nstudents in Computer Applications. Sort them in descending order usingthe Bubble Sort Technique. Display the sorted list. Q estion 5 [15] Define a class to accept a string and convert it into uppercase. Count and display the number of consonants in it. INPUT: HELLO WORLD! OUTPUT: NUMBER OF CONSONANTS: 7 Question 6 [15] Define a class to accept integers into a 4 x 4 matrix and check if it is a nullmatrix. Amatrix is said to be a null matrix if all its elements are zero. [15] -Question 7 Define a class to accept thevalues of integers Mand Nwhere MSN and both Mand Nshould be greater than 1 andless than 1000. Display all the prime numbers between Mand N(both inclusive)using a user defined method isPrime() with the folowing prototype: public static booleanisPrime(int num) [15] Question 8 Define a class to overload the methodshape() as follows: void shape(int size): To draw a square pattern using $ sign as follows: Assuming size = 4 $$$$ $$ $$ voidshape{int w, int h): to draw a rectangular pattern using $ sign as follows: Assuming w=4 and h=3 $$$$ $$ $$$$ 5
|