Formatting page ...
KARNATAKA ICSE SCHOOLS ASSOCIATION ICSE STD. X Preparatory Examination 2025 Subject Computer Applications Duration : 2 hours Maximum Marks : 100 Date: 16.01.2025 General Instructions 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[]. Instruction for the Supervising Examiner Kindly read aloud the Instructions given above to all the candidates present in the Examination Hall. _____________________________________________________________________________ Section A (Attempt all questions from this section) Question 1 Choose the correct answers to the questions from the given options. i. Taking notes Name the feature of Java that is depicted in the given picture. a) Data Abstraction b) Inheritance c) Encapsulation d) Polymorphism ii. What enables Java to be a Write Once, Run Anywhere language? a) Compiler b) Java Virtual Machine (JVM) c) Interpreter d) Operating System iii. The protected access specifier allows access: a) Only within the same class Page 1 of 8 [20] b) Within the same package and by subclasses c) From anywhere d) Only by subclasses in the same package iv. Which of the following has the highest precedence? a) Post-increment (i++) b) Pre-increment (++i) c) Multiplication (*) d) Addition (+) v. Which of the following correctly lists the sizes of primitive data types in Java? a) byte = 1 byte, short = 2 bytes, int = 4 bytes, long = 8 bytes b) byte = 2 bytes, short = 4 bytes, int = 8 bytes, long = 16 bytes c) byte = 1 byte, short = 1 byte, int = 2 bytes, long = 4 bytes d) byte = 4 bytes, short = 4 bytes, int = 8 bytes, long = 8 bytes vi. The output of the statement System.out.println(Math.pow(Math.max(Math.floor(5.7),4),2)); is a) 16.0 b) 36.0 c) 16 d) 25.0 vii. What is the use of the trim() method in Java? a) Removes all spaces in a string b) Removes spaces at the beginning and end of a string c) Replaces spaces with underscores d) Removes a specified character viii. What happens if two case values are identical in a switch statement? a) Both cases will execute b) Only the first case will execute c) Compilation error occurs d) Default case is executed ix. Assertion(A): Constructors are used to initialize objects when they are created in Java. Reasoning(R): A constructor initializes the instance variables of an object when it is created. a) Both Assertion and Reasoning are true, and Reasoning is the correct explanation of Assertion. b) Both Assertion and Reasoning are true, but Reasoning is not the correct explanation of Assertion. c) Assertion is false, but Reasoning is true. d) Assertion is true, but Reasoning is false. x. Which of the following happens automatically in Java during autoboxing? a) A primitive type is automatically converted to a corresponding wrapper class object. b) A wrapper class object is automatically converted to a primitive type. c) Both autoboxing and unboxing occur at the same time. d) Primitive types are converted to arrays of objects. xi. Which code snippet will correctly calculate the sum of all elements in a two-dimensional array arr? Page 2 of 8 a) int sum = 0; for (int i = 0; i < arr.length; i++) { sum += arr[i]; } b) int sum = 0; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++) { sum += arr[i][j]; }} c) int sum = 0; for (int i = 0; i < arr[0].length; i++) { sum += arr[i]; } d) int sum = 0; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i]; j++) { sum += arr[i][j]; } } xii. Assertion: In Java, int and Integer are the same. Reasoning: int is a primitive data type, while Integer is a wrapper class that encapsulates the int type as an object. a) Both Assertion and Reasoning are true, and Reasoning is the correct explanation of Assertion. b) Both Assertion and Reasoning are true, but Reasoning is not the correct explanation of Assertion. c) Assertion is false, but Reasoning is true. d) Assertion is true, but Reasoning is false. xiii. What will be the value of z after the given statements ae executed? int x=7,y=3,z=10; z+=++x%10 + y++*10 + ++z/10; a) 12 b) 45 c) 49 d) 52 xiv. Consider the following program segment where the statements are jumbled, choose the correct order of statements to find the sum of the odd factors of a number. void sum(int n) { sum+=i; for(int i=1;i<=n;i++) { int sum=0; 1 2 3 Page 3 of 8 } if(n%i==0 && i%2!=0) 4 } System.out.println("The sum of the odd fators="+sum); 5 a) 4,1,3,2,5 b) 4,2,3,1,2 c) 3,2,1,3,5 d) 3,2,4,1,5 xv. The output of the given statements is String str="Fantastic"; System.out.println(str.substring(str.length()%4,5)); a) Fant b) anta c) ant d) Fan xvi. Which keyword is used to define a constant value in Java? a) final b) const c) static d) constant xvii. Which of the following is NOT allowed in Java? a) Overloading a method. b) Overloading a constructor. c) Defining multiple constructors in a class. d) Defining a constructor with a return type. xviii. The keyword used to access members of another package. a) import b) static c) class d) switch xix. A method in which the method parameter can get modified is called as ___________ a) Pure method b) Virtual method c) Impure method d)Actual parameters Page 4 of 8 xx. What is the output of the following code? int n[]={5,4,3,2,1}; int b=3; b=n[n[b]/2]; System.out.println(b); a) 2 b) 4 c) 1 d) 5 Question 2 i. Evaluate the given expression. r+=p++ + --q + --p/++r where p=12,q=10 and r=3. [2] 3 ( + )4 ii. Write the java expression for [2] 2 iii. A student when executes the following code, gets the output as 0 1, whereas, he desires to get the output as 0 1 4 9. Identify the statement which has an error, correct the same to get the desired output void main() { int sum=0; for(int i=1;i<=5;i++) { if(i%2==0) break; System.out.print(sum+ \t ); sum=sum+i; } System.out.print(sum); [2] } iv. Write the output of the following string methods. a. String m="Administration", n="Department"; System.out.println(m.substring(2,6)+n.substring(3,6)); b. String p="Microsoft", q="Micro"; System.out.println (q. compareTo (p)); [2] v. How many times will the loop be executed? Write the output of the code. int a=0,b=1; for(a=0;a<=20;a+=5,b++) System.out.println(a+b); System.out.println(b); Page 5 of 8 [2] vi. Rewrite the following code using ternary operator. if (age >= 18) eligibility = "Adult"; else eligibility = "Minor"; [2] vii. A student is trying to convert the given string to a numerical value, but gets an error in the following code. Name the error (syntax/logical/runtime). Give the reason for the error. String s="356.A8"; double p=Double.parseDouble(s); char ch=s.charAt(4); System.out.println(p+ch); [2] viii. Consider the following program segment and answer the following questions. int a[][]={{1,2,3},{4,5,6},{7,8,9}}; a. What is position of 5? b. What is the result of the statement a[0][0]+a[1][2]+a[2][1] [2] ix. Predict the output of the following. char ch="Deer".charAt(2); int a=Character.toUpperCase(ch)+20; System.out.println(ch); System.out.println(a); [2] x. Consider the following program segment and answer the questions given below. class example { int a,b; static int x,y; void perform() { a=10;b=2; int z=a; a=b; b=z; display(); } void display() { System.out.println("Value of a="+a); System.out.println("Value of b="+b); } } a. What will be the values of a and b? b. Name the class variables. [2] Page 6 of 8 SECTION B (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. Buffered Reader / Data Input Stream should not be used in the programs. Question 3 Fashion Courier Service charges for the parcels of its customers as per the following specifications. Class name: FashionCourier Member variables: String name: to store the name of the customer int wt: to store the weight of the parcel in kg double charge: to store the charge of the parcel Member methods: FashionCourier() : default constructor to initialise the member variables with their respective default initial values. void accept(): to accept the name of the customer and weight of the parcel. void compute(): to calculate the charge as per the following criteria. Weight C Charge L Less than 5 kgs RRs. 50 per kg A Above 5 kgs and less than 10 kgs R Rs. 150 per kg A Above 10 kgs and less than 20 kgs RRs. 200 per kg AAbove 20 kgs R Rs. 350 per kg A surcharge of 5% is charged on the bill as well. void display(): to display the name of the customer, weight of the parcel and total bill inclusive of surcharge in a tabular format in the following format : Name Weight Bill amount ***** ***** ******** Define a main method to create an object of the class and call the member methods. [15] Question 4 Write a program to accept 15 integers in a single dimensional array and perform selection sort on the integers and print them in ascending order. [15] Question 5 Write a Java Program to input a string and check it is a palindrome string, a special word or neither. A string is called palindrome when the string is read from left to right or from right to left it is the same string. A string is called special word if it starts and ends with the same character. Sample Input: madam Sample Input: comic Sample Output: Palindrome string Sample Output: Special word Page 7 of 8 Sample Input: cream Sample Output: It is neither a palindrome nor a special [15] Question 6 Write a program to accept a number and calculate the norm of the number. Norm of a number is the square root of the sum of the squares of all digits of the number. Example: The norm of 68 is 10 6 6 + 8x8 = 36+64= 100 Square root of 100 is 10. [15] Question 7 Write a program to accept the integer elements of a 2D array of order mxm. Print the elements in matrix format. Also print the sum of elements of each column. Example: Input: Order of the matrix m=3 a[][]={{1,2,3},{3,4,5},{6,7,8}} Output: 1 1 23 3 3 34 45 5 6 67 78 8 Sum of 1st column=10 Sum of 2nd column=13 Sum of 3rd column=16 [15] Question 8 Define a class to overload the method result() as follows: a. result( )- Print the following series . A,C,E,G . n terms. b. result(int a, int n)- To print the sum of the given series : + + + 1 2 3 c. result(char ch,char ch )- To print the following pattern using the character $ and @ @ @ @ @ $ $ $ @ @ $ Page 8 of 8
|