KnowledgeBoat Logo
|
OPEN IN APP

Question Type 1

Multiple Choice Questions (MCQs)

Class 10 - ICSE Computer Applications Solved Competency Questions



Multiple Choice Questions (1 Mark Each)

Question 1

What is the type of error, if any, when two methods have the same method signature?

  1. Runtime error
  2. Logical error
  3. Syntax error
  4. No error

Answer

Syntax error

Reason — If two methods in the same class have the same method signature (i.e., the same method name and the same parameters), the Java compiler will report a syntax error. This is because Java does not allow duplicate method signatures in the same class as it cannot differentiate which method to call.

Question 2

The advantage/s of user-defined methods are/is:

(i) Reusability
(ii) Complexity
(iii) Modularity

  1. Only (i)
  2. (ii) and (iii)
  3. Only (iii)
  4. (i) and (iii)

Answer

(i) and (iii)

Reason — User-defined methods promote reusability by allowing code to be written once and used multiple times, reducing redundancy. They also support modularity by breaking a program into smaller, manageable, and logically separate units, making it easier to understand, maintain, and debug.

Question 3

Parameters which receive the values from the called method are termed as ............... parameters.

  1. actual
  2. formal
  3. reference
  4. class

Answer

formal

Reason — Parameters that receive values passed from the calling method are called formal parameters. They act as placeholders in the method definition to accept the actual values (actual parameters) during method invocation.

Question 4

Which of the following is a valid method prototype?

  1. public int perform (int a;int b)
  2. public perform (int a, int b)
  3. public int perform (int a, int b)
  4. public perform int (int a, int b)

Answer

public int perform (int a, int b)

Reason — A valid method prototype in Java must specify the access modifier (public), the return type (int), the method name (perform), and the parameter list enclosed in parentheses with parameters separated by commas. The statement public int perform (int a, int b) correctly follows this syntax.

Question 5

Which of the following is the CORRECT statement to invoke the method with the prototype int display(int a, char ch)?

  1. int m = display('A', 45);
  2. int m = display( );
  3. int m = display(A,45);
  4. int m = display(45,'A');

Answer

int m = display(45,'A');

Reason — The method display expects two parameters: the first is an int and the second is a char. Among the options, only display(45, 'A') passes the arguments in the correct order and with the correct types—45 as an integer and 'A' as a character literal.

Question 6

Which of the following is the CORRECT java statement to convert the word RESPECT to lowercase?

  1. "RESPECT".tolowercase( );
  2. "RESPECT".toLowerCase( );
  3. toLowerCase("RESPECT");
  4. String.toLowerCase("RESPECT");

Answer

"RESPECT".toLowerCase( );

Reason — The method to convert a string to lowercase in Java is toLowerCase(), which is called on a string object. It is case-sensitive and must be written exactly as toLowerCase(). Therefore, "RESPECT".toLowerCase() correctly converts the string "RESPECT" to lowercase.

Question 7

Which of the following are Wrapper classes?

(i) Boolean
(ii) boolean
(iii) character
(iv) Character

  1. (i) and (iv)
  2. (ii) and (iv)
  3. (i) and (iii)
  4. (ii) and (iii)

Answer

(i) and (iv)

Reason — Wrapper classes in Java are object representations of primitive data types. Boolean and Character are wrapper classes corresponding to the primitive types boolean and char, respectively.

Question 8

Conversion of a wrapper class to its corresponding primitive type is known as :

  1. unboxing
  2. autoboxing
  3. type casting
  4. parsing

Answer

unboxing

Reason — Unboxing is the automatic conversion of an object of a wrapper class (like Integer, Double, etc.) to its corresponding primitive data type (int, double, etc.).

Question 9

The String method, which results only in a positive integer, is :

  1. indexOf
  2. lastIndexOf
  3. compareTo
  4. length

Answer

length

Reason — The length() method of the String class returns the number of characters in the string as a positive integer. Other methods like indexOf and lastIndexOf return the position of a character or substring, which can be -1 if not found, and compareTo returns an integer that can be positive, negative, or zero depending on lexicographical comparison.

Question 10

The method to convert a String to double is:

  1. String.toDouble()
  2. Double.Parsedouble()
  3. Double.parseDouble(String)
  4. Double.parseDouble()

Answer

Double.parseDouble(String)

Reason — The method parseDouble in the Double class is used to convert a String representing a numeric value into a primitive double type.

Question 11

The java statement System.out.println(x[x.length]) results in:

  1. logical error
  2. syntax error
  3. run time error
  4. no error

Answer

run time error

Reason — In Java, arrays are zero-indexed, meaning the valid indices range from 0 to x.length - 1. x.length gives the total number of elements in the array, but accessing x[x.length] tries to access an index outside the valid range, resulting in a ArrayIndexOutOfBoundsException at runtime.

Question 12

Which of the following is a valid array declaration statement to store the Gender of 80 employees [ 'M'-male, 'F'-female, 'T'-transgender ]?

  1. char gender = new char[80];
  2. char gender[] = new char[80];
  3. char gender[80];
  4. char gender[80] = new char[ ];

Answer

char gender[] = new char[80];

Reason — In Java, arrays must be declared with the type followed by square brackets [] either before or after the variable name. The correct syntax to declare a character array of size 80 is char gender[] = new char[80];.

Question 13

Arrange the following java statements in the correct order of execution to accept values into the array a[]:

(i) a[i]=sc.nextInt( );
(ii) int a[]=new int[10];
(iii) Scanner sc=new Scanner(System.in);
(iv) for(i=0;i<10;i++)

  1. (i), (ii), (iii), (iv)
  2. (ii), (iii), (iv), (i)
  3. (iv), (iii), (ii), (i)
  4. (iii), (i), (iv), (ii)

Answer

(ii), (iii), (iv), (i)

Reason — First, the array a must be declared and initialized (int a[] = new int[10];). Then, the Scanner object sc is created to accept input (Scanner sc = new Scanner(System.in);). Next, a for loop (for(i=0; i < 10; i++)) is used to iterate over the array indices. Inside the loop, values are accepted from the user and stored in the array (a[i] = sc.nextInt();). This sequence ensures proper initialization and input handling.

The statements in the correct order of execution are as follows:

(ii) int a[]=new int[10];
(iii) Scanner sc=new Scanner(System.in);
(iv) for(i=0;i<10;i++)
(i) a[i]=sc.nextInt( );

Question 14

In the bubble sort technique, during each iteration of the inner loop, two adjacent elements are ............... and ............... .

(i) compared
(ii) swapped
(iii) selected
(iv) deleted

  1. (i) and (ii)
  2. (ii) and (iii)
  3. (iii) and (iv)
  4. (ii) and (iv)

Answer

(i) and (ii)

Reason — In the bubble sort technique, during each iteration of the inner loop, two adjacent elements are first compared to check their order. If they are found to be in the wrong order, they are swapped to move the larger element towards the end of the list. This process repeats until the array is sorted.

Question 15

What is the highest index of any array with 100 elements?

  1. 100
  2. 101
  3. 99
  4. 98

Answer

99

Reason — Arrays are zero-indexed, meaning the first element of the array is at index 0. Therefore, an array with 100 elements has indices ranging from 0 to 99. Hence, the highest index is 99.

Question 16

Mr. Sanjay is an event manager, he plans and allots duties to each of his subordinates to handle different events. In a program, a task is divided into simple methods. Name the feature used in these contexts.

  1. Complexity
  2. Modularity
  3. Reusability
  4. Monolithic

Answer

Modularity

Reason — Modularity refers to the practice of dividing a program into separate sub-programs or methods, each handling a specific task. In the context where Mr. Sanjay divides a task into simple methods, the feature being used is modularity.

Question 17

Raj was asked to accept the phone number which has 10 digits, using the appropriate method of Scanner class. Which of the following statement he must choose?

  1. Ob.nextInt()
  2. Ob.nextDouble()
  3. Ob.nextLong()
  4. Ob.next().chatAt(0)

Answer

Ob.nextLong()

Reason — Raj must use Ob.nextLong() because a 10-digit phone number exceeds the range of the int data type. The long data type can handle larger values, making it suitable for storing 10-digit numbers.

Question 18

Raj wanted to count the number of digits in a given number without using a loop. Which of the following statements is correct to perform the above?

  1. String.valueOf(n).length()
  2. Integer.parseInt(n).length()
  3. n.length()
  4. All the above

Answer

String.valueOf(n).length()

Reason — The expression String.valueOf(n).length() converts the number n into a string using String.valueOf(n), and then calculates the number of characters (digits) in that string using .length(). This is a valid and loop-free way to count digits in an integer.

Question 19

Sham was asked to encode a string S, by replacing the letter E with #. Select the appropriate statement:

  1. S.replace('#','E')
  2. S.replace('E')
  3. S.replace('E', '#')
  4. S.replace('#')

Answer

S.replace('E', '#')

Reason — The replace() method in Java is used to replace characters in a string. The correct syntax is S.replace(oldChar, newChar). Since the question asks to replace the letter E with #, we use S.replace('E', '#').

Question 20

When the String m is compared to n, the result obtained is greater than zero. Which of the following is true?

  1. m comes before n in the dictionary.
  2. n comes before m in the dictionary.
  3. m and n are equal.
  4. m and n have the same length.

Answer

n comes before m in the dictionary.

Reason — If comparing string m to n results in a value greater than zero, it means m is lexicographically greater than n. Hence, n comes before m in the dictionary.

Question 21

Which of the following String methods has integer argument?

(i) length
(ii) substring
(iii) indexOf
(iv) charAt

  1. Only (ii)
  2. (i) and (iv)
  3. (ii) and (iv)
  4. (iii) and (iii)

Answer

(ii) and (iv)

Reason — The substring(int beginIndex) and charAt(int index) methods both take an integer argument to specify a position within the string. The substring method returns a part of the string starting from the given index, while charAt returns the character at the specified index.

Question 22

Assertion: Property by virtue of which one class acquires the properties of another class is termed as Inheritance.

Reason: Inheritance promotes reusability.

  1. Assertion is true, Reason is false.
  2. Assertion is true, Reason is true.
  3. Assertion is false, Reason is false.
  4. Assertion is false, Reason is true.

Answer

Assertion is true, Reason is true.

Reason — Inheritance is the property by which one class (subclass) acquires the properties of another class (superclass). It promotes reusability by allowing code to be written once and used by multiple classes.

Question 23

Which of the following is NOT true for polymorphism?

  1. All methods have the same name.
  2. Methods are invoked based on the arguments.
  3. Methods should have the same number and the same type of arguments.
  4. It is a principle of OOPs.

Answer

Methods should have the same number and the same type of arguments.

Reason — Polymorphism allows methods with the same name to behave differently based on the number or type of arguments passed. Hence, methods do not need to have the same number and same type of arguments.

Question 24

Which of the following is a valid initialisation statement?

  1. int x = "GOOD";
  2. int y = 45.0/2;
  3. int z = (int)'x';
  4. int m = false ;

Answer

int z = (int)'x';

Reason

  1. int x = "GOOD";"GOOD" is a String literal, not an integer. We cannot assign a String to a variable of type int.
  2. int y = 45.0/2;45.0 is a double literal, so the result of the division is a double. Assigning a double value to an int without explicit typecasting causes a type mismatch error.
  3. int z = (int)'x'; — This is a valid initialization because the character 'x' is explicitly typecast to an integer, storing its Unicode value in the variable z.
  4. int m = false ;false is a boolean literal. We cannot assign a boolean value to a variable of type int.

Question 25

Which of the following is a valid statement to print the following sentence:

Raj said "Good morning"

  1. System.out.println("Raj said "Good morning");
  2. System.out.println("Raj said \\Good morning\\);
  3. System.out.println("Raj said \"Good morning\" ");
  4. System.out.println("Raj said Good morning");

Answer

System.out.println("Raj said \"Good morning\" ");

Reason — The statement System.out.println("Raj said \"Good morning\" "); is valid because it uses the escape sequence \" to include double quotes inside the string. This ensures the output displays exactly as Raj said "Good morning".

Question 26

Which data structure is represented in the below picture?

Which data structure is represented in the below picture? Computer Application Competency Focused Practice Questions Class 10 Solutions.

(i) A two-dimensional array with 2 rows and seven columns.
(ii) A one-dimensional array with 14 elements.

  1. Both (i) and (ii)
  2. Only (i)
  3. Only (ii)
  4. None of the (i) and (ii)

Answer

Only (i)

Reason — A two-dimensional array is a collection of elements arranged in rows and columns. The ice tray shown in the figure looks like a grid with 2 rows and 7 columns, just like a 2D array.

Question 27

What is the type of looping statement depicted in the below picture?

What is the type of looping statement depicted in the below picture? Computer Application Competency Focused Practice Questions Class 10 Solutions.
  1. Entry controlled loop
  2. Exit controlled loop
  3. Multiple branching statement
  4. All the above.

Answer

Entry controlled loop

Reason — An entry controlled loop checks the condition before executing the loop body. In the figure, the condition is evaluated first, and the commands run only if the condition is true, which matches the behaviour of an entry controlled loop like a while loop.

Question 28

What is the process done in the below picture?

What is the process done in the below picture? Computer Application Competency Focused Practice Questions Class 10 Solutions.
  1. Sorting the list in descending order
  2. Searching the character in the list
  3. Sorting the list in ascending order.
  4. None of the above.

Answer

Sorting the list in ascending order.

Reason — The characters in the list are rearranged from an unordered sequence (B, D, A, C) to an ordered sequence (A, B, C, D) following the alphabetical order, which is called sorting in ascending order.

Question 29

Name the method of search depicted in the below picture.

Name the method of search depicted in the below picture. Computer Application Competency Focused Practice Questions Class 10 Solutions.
  1. Binary Search
  2. Selection Sort
  3. Bubble Sort
  4. Linear Search

Answer

Linear Search

Reason — In Linear Search, each element in the list is checked one by one from the beginning until the required value is found. In the picture, the search starts at the beginning and checks each value one after the other until it finds '6', which matches the method of Linear Search.

Question 30

Name the feature of Java depicted in the below picture.

Name the feature of Java depicted in the below picture. Computer Application Competency Focused Practice Questions Class 10 Solutions.
  1. Encapsulation
  2. Inheritance
  3. Polymorphism
  4. Data abstraction

Answer

Polymorphism

Reason — Polymorphism means "many forms." In Java, it refers to the ability of a single object to behave differently in different situations. Just like the same person behaves like a customer in a mall, passenger in a bus, student in school, and son at home.

Question 31

Name the data types in order from top, given in the above picture.

Name the data types in order from top, given in the above picture.Computer Application Competency Focused Practice Questions Class 10 Solutions.
  1. int, char, double, String
  2. String, int, char, double
  3. char, double, int, String
  4. int, double, char, String

Answer

String, int, char, double

Reason

  • The first value is a sentence in quotes, which is a String.
  • The second value is 578, a whole number without decimal, so it is of int type.
  • The third value is \n, which is an escape sequence representing a character, hence char type.
  • The fourth value is 51.048053, a number with decimals, which is of double type.

Question 32

How many bytes are occupied by the below two-dimensional array?

1562015420
1302013020
16217.6716120
15817.515420
  1. 96 bytes
  2. 128 bytes
  3. 12 bytes
  4. 24 bytes

Answer

128 bytes

Reason — The given table represents a 4×4 two-dimensional array (4 rows and 4 columns), which means there are 16 elements in total. The values include both integers and decimal numbers, indicating that the array is of double data type (which can store both whole numbers and decimal numbers).

In Java, a double occupies 8 bytes.
So, total bytes = 16 elements × 8 bytes = 128 bytes.

Question 33

A girl wanted to calculate the sum of two numbers stored as a and b multiplied by 7. Select the appropriate Java expression.

  1. a + b*7
  2. 7*a + b
  3. (a + b)*7
  4. a + 7*b

Answer

(a + b)*7

Reason — To calculate the sum of two numbers stored as a and b multiplied by 7, we use parentheses to add a and b first, then multiply the result by 7. The correct expression is (a + b)*7.

Question 34

The sum of a[1] and a[3] in the array int a[] = {20, 40, 60, 80, 100} is:

  1. 80
  2. 100
  3. 120
  4. 60

Answer

120

Reason — In the array int a[] = {20, 40, 60, 80, 100}, the index starts from 0.

  • a[1] refers to the second element: 40

  • a[3] refers to the fourth element: 80

So, the sum is: 40 + 80 = 120.

Question 35

State which access specifier is less restrictive.

State which access specifier is less restrictive. Computer Application Competency Focused Practice Questions Class 10 Solutions.
  1. private
  2. protected
  3. default
  4. public

Answer

public

Reason — The public access specifier is the least restrictive because it allows access to the class members from any other class, anywhere in the program.

Question 36

The AMB hotel gives the amount to be paid by the customer as an integer, which of the following Math method rounds off the bill in decimals to an integer?

  1. Math.round()
  2. Math.pow()
  3. Math.ceil()
  4. Math.abs()

Answer

Math.round()

Reason — The Math.round() method rounds a decimal number to the nearest integer. It returns the closest whole number, which is suitable for rounding off a bill amount to an integer.

Question 37

Identify which of the following leads to an infinite loop.

  1. for(i = 10; i != 0; i--)
  2. for(i = 3; i <= 30; i += 3)
  3. for(i = 1; i >= 1; i++)
  4. for(i = 1; i >= 0; i--)

Answer

for(i = 1; i >= 1; i++)

Reason — In the loop for(i = 1; i >= 1; i++), the condition i >= 1 will always be true because i starts at 1 and increases by 1 in each iteration. Since i is always greater than or equal to 1, the loop condition never becomes false. Therefore, the loop runs infinitely, causing an infinite loop.

Question 38

Assertion: A class can have multiple constructors.

Reason: Multiple constructors are defined with same set of arguments.

  1. Assertion is true, Reason is false.
  2. Both assertion and Reason are false.
  3. Both assertion and Reason are true.
  4. Assertion is false, Reason is true.

Answer

Assertion is true, Reason is false.

Reason — A class can have multiple constructors, this is called constructor overloading. However, multiple constructors cannot have the same set of arguments because that would cause ambiguity. Each constructor must have a different number or type of parameters.

Question 39

Assertion: An array can store elements of different data types.

Reason: An array is a user-defined data type with multiple values of the same data type but a different memory index.

  1. Assertion is true, Reason is false.
  2. Both assertion and Reason are false.
  3. Both assertion and Reason are true.
  4. Assertion is false, Reason is true.

Answer

Assertion is false, Reason is true.

Reason — An array is a user-defined data type that stores multiple values of the same data type at different memory locations. It cannot store elements of different data types.

Question 40

Which of the following statement is an example for explicit typecasting?

  1. int amount = 45;
  2. int amount = 24*24;;
  3. int amount = Integer.parseInt("45")
  4. int amount = (int)45.75;

Answer

int amount = (int)45.75;

Reason — Explicit typecasting is when we manually convert one data type to another by specifying the type in parentheses. Here, (int)45.75 converts the double value 45.75 to an int by removing the decimal part.

Question 41

The output of the statement Math.ceil.(89.9) + Math.floor(90.5) is:

  1. 0.0
  2. 180
  3. 180.0
  4. 180.4

Answer

180.0

Reason

  • Math.ceil(89.9) returns the smallest integer greater than or equal to 89.9, which is 90.0.
  • Math.floor(90.5) returns the largest integer less than or equal to 90.5, which is 90.0.
  • Adding them: 90.0 + 90.0 = 180.0

So, the output is 180.0.

Question 42

The output of the statement of "TIGER".indexOf('G') is:

  1. 3
  2. 2
  3. -1
  4. 0

Answer

2

Reason — The indexOf() method in Java returns the position (index) of the first occurrence of the specified character in the string.
In the string "TIGER":

  • T is at index 0
  • I is at index 1
  • G is at index 2

So, "TIGER".indexOf('G') returns 2.

Question 43

Choose the statement which is equivalent to the given:

if(a>b) 
System.out.println("Honest"); 
else 
System.out.println("Sincere");
  1. a>b? System.out.println("Honest"):System.out.println("Sincere");
  2. System.out.println(a>b? "Honest":"Sincere");
  3. a>b? "Honest": "Sincere";
  4. a>b: "Honest"? "Sincere";

Answer

System.out.println(a>b? "Honest":"Sincere");

Reason — The ternary operator condition ? value1 : value2 is used to select one of two values based on a condition. The above if-else statement can be rewritten using the ternary operator inside the println() method as: System.out.println(a > b ? "Honest" : "Sincere");. This statement prints "Honest" if a > b, otherwise it prints "Sincere".

Question 44

The two Java statement are used to check for the equality of the strings "COP" and "cop" are as follows:

"COP".equals("cop") 
"COP".equalsIgnoreCase("cop")

The output of the above statements is:

  1. false, true
  2. true, false
  3. false, false
  4. true, true

Answer

false, true

Reason — In Java:

  • "COP".equals("cop") checks for exact match, including uppercase and lowercase letters. Since "COP" and "cop" are not exactly the same, it returns false.
  • "COP".equalsIgnoreCase("cop") checks for equality by ignoring the case of letters. So it treats "COP" and "cop" as equal and returns true.

Question 45

The output of the java statement "SOLDIER".compareTo("SOLUTE"); is

  1. -4
  2. -17
  3. 17
  4. 0

Answer

-17

Reason — The compareTo() method in Java compares two strings lexicographically using the Unicode values.

Let's compare "SOLDIER" and "SOLUTE":

  • The first three letters S, O, L are the same in both strings.
  • The 4th letter in "SOLDIER" is 'D' and in "SOLUTE" it is 'U'.
  • Unicode of 'D' = 68, Unicode of 'U' = 85.
  • 68 − 85 = -17

So, the output is -17.

Question 46

Arrange the following in the descending order of number of bytes occupied.

(i) char x[20]
(ii) int a[4][2]
(iii) double b[6]

  1. (iii), (ii), (i)
  2. (iii), (i), (ii)
  3. (ii), (iii), (i)
  4. (i), (ii), (iii)

Answer

(iii), (i), (ii)

Reason — To find the number of bytes occupied by each array, we multiply the number of elements by the size of each data type:

(i) char x[20] — 20 elements * 2 bytes = 40 bytes
(ii) int a[4][2] — 4 * 2 = 8 elements * 4 bytes = 32 bytes
(iii) double b[6] — 6 elements * 8 bytes = 48 bytes

Now arranging in descending order: (iii) 48 bytes, (i) 40 bytes, (ii) 32 bytes

Question 47

Sam performs bubble sort on the following array to organise the elements in ascending order:
{5, 1, 2, 3}

After the first comparison the array is:
{1, 5, 2, 3}

What would be the array after the next comparison?

  1. {1, 2, 5, 3}
  2. {1, 5, 3, 2}
  3. {1, 3, 5, 2}
  4. {1, 3, 2, 5}

Answer

{1, 2, 5, 3}

Reason — In Bubble Sort, adjacent elements are compared and swapped if they are in the wrong order.

Original array: {5, 1, 2, 3}
After the first comparison (compare 5 and 1):
Since 5 > 1, they are swapped → {1, 5, 2, 3}

Next comparison (second comparison):
Compare 5 and 2. Since 5 > 2, they are swapped → {1, 2, 5, 3}

So, after the next comparison, the array becomes {1, 2, 5, 3}.

PrevNext