ICSE Class 10 Computer Applications Sample Question Paper 17 with Answers

ICSE Class 10 Computer Applications Sample Question Paper 17 with Answers

Maximum Marks: 50
Time: 2 Hours

Section – A [10 Marks]
Attempt all questions

Question 1.
Choose the correct answers to the questions from the given options. (Do not copy the question, write the correct answer only)
(i) The output of “VIDYALAYA.”substring(2,5) will result in.
(a) DYA
(b) DYAL
(c) YAL
(d) None of these
Answer:
(a) DYA
Explanation:
substring(2,5) returns characters from index 2 to 4.

ICSE Class 10 Computer Applications Sample Question Paper 17 with Answers

(ii) The replace() function requires at least parameters.
(a) 1
(b) 2
(c) 3
(d) 0
Answer:
(b) 2
Explanation:
The replace() function requires at least 2 parameters, the character to be replaced and the replacement character.

(iii) ………….. and …………. are the numeric wrapper classes in java.
(a) String and Integer
(b) STRING and INTEGER
(c) Byte and Short
(d) Int and Byte
Answer:
(c) Byte, Short
Explanation:
The numeric wrapper classes in Java are Byte, Short, Integer, Long, Float, Double,

ICSE Class 10 Computer Applications Sample Question Paper 17 with Answers

(iv) The statement that converts the string object s=”400″ to integer “s_int” is ………….
(a) s_int=Integer.parse(s);
(b) s_int=Integer.Int(s);
(c) s_int=lnteger.parselnt(s);
(d) s_int=integer.parselnt(s);
Answer:
(c) s_int=lnteger.parselnt(s);
Explanation:
The Integer class’s parselnt() method converts a string to integer.

(v) The trim() function removes spaces from:
(a) Left of a string
(c) Both sides of a string
(b) Right of a string
(d) Middle of a string
Answer:
(c) Both sides of a string
Explanation:
The trim() function removes extra spaces from both sides of a string.

ICSE Class 10 Computer Applications Sample Question Paper 17 with Answers

(vi) The function that checks whether a character is a tab space or not.
(a) isTabSpace()
(c) isWhiteSpace()
(b) isSpace()
(d) isWHITESpace()
Answer:
(c) isWhiteSpace()
Explanation:
The isWhiteSpace() function checks whether a character carries a tab or a white space.

(v) Given an array ar[]={10,20,30,40,50}, the statement ar[3] – l will return:
(a) 30
(b) 40
(c) 39
(d) 10
Answer:
(c) 39
Explanation:
ar[3] returns 40, so ar[3]-l will return 39

ICSE Class 10 Computer Applications Sample Question Paper 17 with Answers

(vi) To add a value 5 to each element of an array myarr the expression myarr+5 is correct.
(a) True
(b) False
Answer:
(b) False
Explanation:
In java, values cannot be added to array like this, we need a loop here.

(vii) Which of the following functions has a different nature?
(a) isLowerCase()
(b) isDigit()
(c) isUpperCase()
(d) toUpperCase()
Answer:
(d) toUpperCase()
Explanation:
All the other functions check a value and return in Boolean True or False. toUpperCase() returns a char.

ICSE Class 10 Computer Applications Sample Question Paper 17 with Answers

(viii) The maximum arguments that the indexOf() function can be provided with is:
(a) 1
(b) 2
(c) 3
(d) 4
Answer:
(a) 1
Explanation:
The indexOf() function takes only 1 argument that is the character whose index is to be found.

Section – B  (40 Marks)
Attempt any four questions

Attempt any four questions from this Section
The answers in this Section should consist of the Programs in either Blue J environment or any program environment with Java as the base. Each program should be written using Variable descriptions/Mnemonic Codes such that the logic of the program is clearly depicted. Flow-Charts and Algorithms are not required.

Question 2.
Write a program to input a sentence. Find and display the following:
(i) Number of words present in the sentence
(ii) Number of letters present in the sentence
Assume that the sentence has neither include any digit nor a special character.
Answer:

import java.util.Scanner;
public class WordsNLetters
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter a sentence:");
String str = in.nextLine();
int wCount = 0,
ICount = 0;
int len = str.length();
for (int i = 0; i < len; i++)
{
char ch = str.charAt(i);
if (ch ='')
wCount++;
else
lCount++;
}
/*
* Number of words in a sentence are one more than
* the number of spaces so incrementing wCount by 1
*/
wCount++;
System.out.println("No. of words = " + wCount);
System.out.println("No. of letters = " + ICount);
}
}

ICSE Class 10 Computer Applications Sample Question Paper 17 with Answers

Question 3.
Write a program in Java to accept a String in upper case and replace all the vowels present in the String with Asterisk (*) sign.
Sample Input: “RELIANCE INDUSTRIES”
Sample output: R*L**NC* *ND*STR**S
Answer:

import java.util.Scanner;
public class VowelReplace
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter a string in uppercase:");
String str = in.nextLine();
String newStr = "";
int len = str.length();
for (int i = 0; i < len; i++)
{
char ch = str.charAt(i);
if (ch == A' I I
ch = 'E' I I
ch = T I I
ch = 'O' I I
ch = 'U')
{
newStr = newStr + '*';
}
else
{
newStr = newStr + ch;
}
}
System.out.println(newStr);
}
}

ICSE Class 10 Computer Applications Sample Question Paper 17 with Answers

Question 4.
Write a program in Java to enter a sentence. Frame a word by joining all the first characters of each word of the sentence. Display the word.
Sample Input: INDIAN SPACE AGENCY
Sample Output: ISA
Answer:

import java.util.Scanner;
public class FrameWord
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter a sentence:");
String str = in.nextLine();
String word = "" + str.charAt(O);
int len = str.length();
for (int i = 0; i < len; i++)
{
char ch = str.charAt(i);
if (ch =='')
word += str.charAt(i + 1);
}
System.out.println(word);
}
}

ICSE Class 10 Computer Applications Sample Question Paper 17 with Answers

Question 5.
Write a program to accept a list of 20 integers. Sort the first 10 numbers in ascending order and next the 10 numbers in descending order by using ‘Bubble Sort’ technique. Finally, print the complete list of integers.
Answer:

import java.util.Scanner;
public class BubbleSort
{
public static void main(String argsQ)
{
Scanner in = new Scanner(System.in);
int arr[] = new int[20];
System.out.println("Enter 20 numbers:");
for (int i = 0; i < arr.length; i++)
{
arr[i] = in.nextlntQ;
}
//Sort first half in ascending order
for (int i = 0; i < arr.length / 2 -1; i++)
{
for (int j = 0; j < arr.length / 2 - i -1; j++) { if (arr[j] > arr[j + 1])
{
int t = arr[j + 1];
arr[j + 1] = arr[j];
arr[j] = t;
}
}
}
//Sort second half in descending order
for (inf i = 0; i < arr.length / 2-1; i++)
{
for (int j = arr.length / 2; j < arr.length - i -1; j++)
{
if (arr[j] < arr[j + 1])
{
int t = arr[j + 1];
arr[j + 1] = arr[j];
arr[j] = t;
}
}
}
//Print the final sorted array System.out.println("\nSorted Array:");
for (int i = 0; i < arr.length; i++)
{
System.out.print(arr[i] + " ");
}
}
}

ICSE Class 10 Computer Applications Sample Question Paper 17 with Answers

Question 6.
Write a program in Java to accept 20 numbers in a single dimensional array arr[20]. Transfer and store all the even numbers in an array even[ ] and all the odd numbers in another array odd[ ]. Finally, print the elements of both the arrays.
Answer:

import java.util.Scanner;
public class EvenOddProgs
{
public static void main(String args[])
{
final int NUM_COUNT = 20;
Scanner in = new Scanner(System.in);
int i = 0;
int arr[] = new int[NUM_COUNT];
int even[] = new int[NUM_COUNT];
int odd[] = new int[NUM_COUNT];
System.out.println("Enter 20 numbers:");
for (i = 0; i < NUM_COUNT; i++)
{
arr[i] = in.nextlnt();
}
int eldx = 0,
oldx = 0;
for (i = 0; i < NUM_COUNT; i++)
{
if (arr[i] % 2 = 0)
even[eldx++] = arr[i];
else
odd[oldx++] = arr[i];
}
System.out.println("Even Numbers:");
for (i = 0; i < eldx; i++)
{
System.out.print(even[i] + " ");
}
System.out.println("\nOdd Numbers:");
for (i = 0; i < oldx; i++)
{
System.out.print(odd[i] + " ");
}
}
}

ICSE Class 10 Computer Applications Sample Question Paper 17 with Answers

Question 7.
Write a program to store 20 numbers in a Single Dimensional Array. Now, display only those numbers that are perfect squares.

n[0] n[1] n[2] n[3] n[4] n[5] n[16] n[l 7] n[18] n[19]
12 45 49 78 64 77 81 99 45 33

Sample Output: 49, 64, 81
Answer:

import java.util.Scanner;
public class PerfectSquares
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
inf arr[] = new int[20];
System.out.println(,/Enter 20 numbers");
for (inf i = 0; i < arr.length; i++)
{
arr[i] = in.nextlnt();
}
System.out.println(//Perfect Squares are:");
for (inf i = 0; i < arr .length; i++)
{
double sr = Math.sqrt(arr[i]);
if ((sr - Math.floor(sr)) = 0)
System.out.print(arr[i] + ", ");
}
}
}
ICSE Class 10 Computer Applications Question Papers with Answers

Leave a Comment