Trending ▼   ResFinder  

ICSE Class X Sample / Model Paper 2025 : Computer Applications

8 pages, 40 questions, 0 questions with responses, 0 total responses,    0    0
Saptarshi Dev Barman
  
+Fave Message
 Home > saptarshi2009 >

Formatting page ...

CLASS X Sample Paper I COMPUTER APPLICATION SECTION - A[40 marks] QUESTION 1 (Multiple Choice Questions) [15 1=15] I . What will this print? String s = "abc"; s.concat("def"); System.out.println(s); A. abc B. abcdef C. def D. Error II. What will happen when the following code is executed? int[] arr = null; A) Prints 0 System.out.println(arr[0]); B) NullPointerException C) Compilation Error D) Prints null III. What is the correct way to print the last element of a 2D array arr? A) arr[arr.length - 1][arr[0].length - 1] B) arr[arr.length][arr.length] C) arr[arr.length][0] D) arr[0][arr.length - 1] IV. Which of the following statements is true about objects in Java? A. Two objects with the same data are always considered equal. B. == compares the content of two objects. C. equals() must be overridden to compare object content. D. Objects are always passed by reference in Java. V. What will be the output of the following code? public static void tricky(int a, int b) { a = a + b; b = a - b; a = a - b; System.out.println(a + " " + b); } public static void main(String[] args) { int x = 5, y = 10; tricky(x, y); System.out.println(x + " " + y); } A. 10 5 then 10 5 B. 5 10 then 10 5 C. 10 5 then 5 10 D. 5 10 then 5 10 VI. Which of the following is not true about constructors in Java? A. Constructors can be overloaded. B. Constructors can be inherited. C. The constructor can call another constructor. D. Constructors can be private. VII. Which of the following method calls is invalid? Given: public class Demo { public void test(int a) {} public void test(double a) {} public static void test(String a) {} } A. Demo d = new Demo(); d.test(5); B. Demo.test("Hello"); C. Demo d = new Demo(); d.test(5.5); D. Demo d = new Demo(); Demo.test("Hello"); VIII. Given: int[][] arr = new int[4][3]; What is arr.length? TEST PAPER - 1 A) 3 B) 4 C) 12 D) 7 CLASS X Sample Paper I IX. Which of the following statements about Java is true? A) Java is compiled and then interpreted B) Java code is only compiled C) Java is only interpreted D) Java code cannot run on different platforms X. What will be the output of the following code? class Overload { int x; double y; void add(int a, int b) { x = a + b; } void add(double c, double d) { y = c + d; } Overload() { x = 0; y = 0; } } class Overload_methods { public static void main(String[] args) { Overload obj = new Overload(); int a = 2; double b = 3.2; obj.add(a, a); obj.add(b, b); System.out.println(obj.x + " " + obj.y); } } A) 4 6.4 B) 6.4 6 C) 6.4 6.4 D) 6 6 XI. Which statement about variable scope in Java is true? A) A local variable is accessible throughout the class in which it is declared. B) Instance variables can be accessed directly from static methods. C) Static variables are shared among all instances of a class. D) Method parameters are accessible outside the method after it finishes execution. XII. Assertion (A): In Java, an array of strings can be declared and initialized as: String[] arr = {"hello", "world"}; Reason (R): Each element in the string array behaves as a separate string object that supports string methods like .length() and .charAt(). A) Both A and R are true, and R is the correct explanation of A B) Both A and R are true, but R is not the correct explanation of A C) A is true, R is false D) Both A and R are false XIII. int[] arr = new int[]{1, 2, 3, 4, 5}; int i = 2; arr[i++] = arr[++i] + arr[i--]; System.out.println(arr[2] + " " + arr[3] + " " + arr[4]); What is the output? A) 7 4 5 B) 8 4 5 C) 6 4 5 D) Compilation Error XIV. When are method parameters evaluated? a) At compile time b) At runtime c) At load time d) After method completion XV. String s = "java programming java"; System.out.println(s.substring(s.indexOf("a"), s.lastIndexOf("m")).startsWith("a") + " " + s.substring(s.indexOf("p"), s.lastIndexOf("g")).endsWith("g") ); What is the output? A) true false TEST PAPER - 1 B) false true C) true true D) false false CLASS X Sample Paper I XVI. Which of the following statements about Java Library Classes is correct l? A) Library classes are pre-written user-defined classes that programmers must compile before use. B) Wrapper classes in Java provide a way to use primitive data types as objects and support autoboxing and unboxing. C) The Scanner class is used for string manipulation similar to the StringBuilder class. D) Java library classes only provide graphical user interface (GUI) capabilities and not utility methods for data processing. XVII. int sum = 0; boolean exit = false; for (int i = 1; i <= 5 && !exit; i++) { for (int j = 1; j <= 5; j++) { if (i * j > 6) { exit = true; break; } if ((i + j) % 2 == 0) { continue; } sum += i + j; } } System.out.println(sum); What is the output ? A) 18 B) 21 C) 24 D) 27 XVIII. Which of the following statements is correct ? A) Encapsulation allows direct access to private data members from subclasses via inheritance. B) A subclass inherits all public and private members of its superclass by default. C) Encapsulation is achieved by declaring data members private and providing public getter and setter methods, enabling controlled access and supporting inheritance for code reuse. D) Objects cannot inherit properties or methods from other objects; inheritance works only with primitive data types. XIX. What does this code print? String s1 = "hello"; String s2 = new String("hello"); int count = 0; for (int i = 0; i < s1.length(); i++) if(s1.substring(i, i + 1) == s2.substring(i, i + 1)) count++; System.out.println(count); a) 0 b) 5 c) Compilation error d) 1 XX. What will be the output? String s = "xy"; for (int i = 0; i < s.length(); i++) for (int j = i; j < s.length(); j++) System.out.print(s.substring(i, j + 1) + " "); a) x xy y TEST PAPER - 1 b) xy c) x y xy d) x y CLASS X Sample Paper I Questions 2: 1.Study the following Java snippet and determine the output: [2] String s = "abc"; s += s.charAt(s.length() - 1) + s.substring(0, 2); s = s.replace(s.substring(1, 3), s.substring(2)); s += s.charAt(0) + s.substring(s.indexOf('a')); System.out.println(s); 2. Identify and underline errors in the snippet, mention the type , and then correct them. [2] int a[] = {4, 1, 0, 3}; int total = 0; for(int i = 0; i <= a.length; i++) { for(int j = i; j < a.length; j++); { if(a[j] / 2 == 0) total = total + a[i] * a[j]; } } System.out.println("Result = " + to); 3. Print the array after the calculation [3 2=6] (i) int[][] m = { {1, 2, 3}, {4, 5}, {6, 7, 8} }; m[1] = m[2]; m[0][m[1][0] - 5] = m[1][1] + m[0][1]; m[1][1] = ++m[0][2 - 1]; m[2][0] = m[m[0][1] % 2][m[1][1] - 7]; (ii) int[][] a = { {1, 2, 3}, null, {4, 5, 6} }; a[1] = a[0]; a[a[2][0] / 4][a[0][2] - 3] = a[2][1] + a[0][0]; a[2][a[1][1] - 1] = a[0][2] + a[2][0]; a[0] = a[2]; (iii) int[][] arr = { {2, 3}, {4, 5, 6}, {7} }; int x = 1, y = 2; arr[x++][--y] += arr[--x][y++]++ + ++arr[y][x--]; 4. State how many times the inner loop will execute and state the output: [2] int x = 2, y = 5, z = 1; for (int i = 1; i < y; i++) { for (int j = i; j <= x; j++) { z += (i + j) % 3; if (z % 2 == 0) x++; else y--; } System.out.println(x + " " + y + " " + (z - i + (x % y))); TEST PAPER - 1 CLASS X Sample Paper I 5. State the output: [1 4 =4] (i) int x = 'A', y = x++ + ++x - 'B' + (x = 'C'); System.out.println((char)(y - x) + " " + x + " " + y); (ii) String s = "A" + 'B' + (1 + 2) + 'C' + "D" + (s = "E"); System.out.println(s); (iii) String s = "X"; for(int i = 0; i < s.length(); s += (s = s + i).charAt(i++)); System.out.println(s); (iv) boolean b = (5 + 'A') > ('B' - 1); String s = b + "" + (b = !b) + (b ? (int)'A' : 'a') + ("" + (b = !b) + b); System.out.println(s); 6. Without using Math.cbrt() or Math.sqrt() directly, write a single Java expression that correctly evaluates the value of for positive real numbers x and y, ensuring that the cube root works correctly even if x is negative. [1] [Math.pow(x < 0 ? -Math.pow(-x, 1.0/3) : Math.pow(x, 1.0/3), 1) + Math.pow(y, 0.5)] 7. What will be the final contents of the array arr after all the statements are executed? [2] int arr[] = {5, -3, 8, 2, -6, 9, 4}; arr[1] = ++arr[3] + arr[0]-- - arr[2] / 2; arr[4] = Math.abs(arr[1]) + (--arr[6]); arr[2] = arr[arr[3] % 3] + arr[4]; arr[5] = (int)Math.pow(arr[2] % 10, 2) - arr[0]; arr[0] += arr[5] / 3 - arr[4]; arr[3] = arr[3]++ + --arr[2] - arr[6]; arr[6] = Math.max(arr[4], arr[5]) - arr[1]; arr[1] = arr[0] + arr[2] - arr[3] + arr[6]; 8. Write the java statement from the following (i). (ii) . TEST PAPER - 1 CLASS X Sample Paper I SECTION - B[60 marks] [Attempt any four programs ] QUESTION 4 Given an array of n non-negative integers arr[] representing an elevation map where the width of each bar is 1, compute how much water it can trap after rain. Input: arr[] = [3, 0, 1, 0, 4, 0, 2] Output: 10 Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 QUESTION 5 Given a string str and an integer k, the task is to reduce the string by applying the following operation any number of times until it is no longer possible: Choose a group of k consecutive identical characters and remove them from the string. Finally, print the reduced string. Input: K = 2, str = "geeksforgeeks" Output: gksforgks Input: K = 3, str = "qddxxxd" Output: q QUESTION 6 Given a 2D binary matrix mat[][] consisting only of 0s and 1s, find the area of the largest rectangle sub-matrix that contains only 1s. Input: mat[][] = [[0, 1, 1, 0], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 0, 0]] Output: 8 Explanation: The largest rectangle with only 1's is from (1, 0) to (2, 3) which is Input: mat[][] = [[0, 1, 1], [1, 1, 1], [0, 1, 1]] Output: 6 Explanation: The largest rectangle with only 1's is from (0, 1) to (2, 2) which is TEST PAPER - 1 CLASS X Sample Paper I QUESTION 7 Given are two strings, input string and a mask string that remove all the characters of the mask string from the original string. Example: INPUT: ORIGINALSTRING: communication MASK STRING: mont OUTPUT: cuicai A class StringOp is defined as follows to perform above operation. Some of the members of the class are given below: Class name : StringOp Data members/instance variables: nstr : to store the original string msk : to store the mask string nstr : to store the resultant string Methods / Member functions: StringOp() : default constructor to initialize the data member with legal initial value void accept( ) : to accept the original string str and the mask string msk in lower case void form() :to form the new string nstr after removal of characters present in mask from the original string void display( ) : to display the original string and the newly formed string nstr Specify the class StringOp giving details of the constructor( ), void accept( ), void form() and void display( ). Define a main( ) function to create an object and call all the functions accordingly to enable the task. QUESTION 8 Given a matrix of size n * m. Find the maximum path sum in the matrix. The maximum path is the sum of all elements from the first row to the last row where you are allowed to move only down or diagonally to left or right. You can start from any element in the first row. Examples: Input: mat[][] = {10 10 2 0 20 4 1 0 0 30 2 5 0 10 4 0 2 0 1 0 2 20 0 4} Output: 74 Explanation: The maximum sum path is 20-30-4-20. Input: mat[][] = {1 2 3 987 4 5 6} Output: 17 Explanation: The maximum sum path is 3-8-6. TEST PAPER - 1 CLASS X Sample Paper I QUESTION 9 Given three separate problems, design a class MultiOp using user-defined methods to perform the following string and array operations: 1. Check whether a given string can be rearranged to form a palindrome. Input: tactcoa Output: Yes, it can be rearranged into a palindrome. 2. Find the largest sum of a contiguous subarray. Example: Input: [-2, 1, -3, 4, -1, 2, 1, -5, 4] Output: 6 (subarray [4, -1, 2, 1]) 3. Find the length of the longest substring without repeating characters. Example: Input: abcabcbb Output: 3 (substring "abc") A class MultiOp is defined as follows to perform the above operations. Class name: MultiOp Data members / Instance variables Description String str To store an input string int[] arr To store an integer array int n To store the size of the array Method Description MultiOp() Default constructor to initialize instance variables with legal values. void inputString() To accept a string from the user. void inputArray() To accept elements of an integer array from the user. boolean canPal(String str) To check whether the string can be rearranged to form a palindrome. int largestSum(int[] arr) To calculate and return the largest sum of a contiguous subarray. int longestSub(String str) To calculate and return the length of the longest substring without repeating characters. void display() To display the results of all three operations. Tasks 1. Specify the class MultiOp giving details of the constructor, input methods, user-defined methods, and display method. 2. Define a main() function to create an object of the class and call all the methods accordingly to enable the tasks. TEST PAPER - 1

Formatting page ...

Related ResPapers
ICSE Class X Sample / Model Paper 2025 : Computer Applications
by 7866sameer 
ICSE Class X Sample / Model Paper 2025 : Computer Applications
by prcpt 
ICSE Class X Sample / Model Paper 2023 : Computer Applications
by ramcharan25 
ICSE Class X Sample / Model Paper 2021 : Computer Applications
by coolsroy_mdp 

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

 

  Print intermediate debugging step

Show debugging info


 

 


© 2010 - 2025 ResPaper. Terms of ServiceContact Us Advertise with us

 

saptarshi2009 chat