ICSE Class 10 Computer Applications Sample Question Paper 16 with Answers

ICSE Class 10 Computer Applications Sample Question Paper 16 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) Which feature can be implemented using encapsulation?
(a) Inheritance
(b) Abstraction
(c) Polymorphism
(d) Overloading
Answer:
(b) Abstraction
Explanation:
Data abstraction can be achieved by using encapsulation. We can hide the operation and structure of actual program from the user and can show only required information by the user

ICSE Class 10 Computer Applications Sample Question Paper 16 with Answers

(ii) If String x = “Computer”; String y = “Applications”;
What do the following function returns ?
System.out.println(x.equals(y));
(a) true
(b) false
(c) 9
(d) Computer
Answer:
(b) false
Explanation:
As strings x and y are not equal so x.equals(y) returns false.

(iii) The output of the statement, when executed : System.out.println(“Object Oriented” .length()); is :
(a) 16
(b) 17
(c) 15
(d) 19
Answer:
(c) 15
Explanation:
The length() function returns the number of characters in a String.

(iv) Predict the output
String str = “Computer Applications” + 1 + 0;
System.out.println(“Understanding” + str);
(a) UnderstandingComputer Applications10
(c) Computer Applications10
(b) understandingcomputer applications10
(d) Computer Applications
Answer:
(a) Understanding Computer ApplicationslO
Explanation:
In the first line, + operator concatenates 1 and 0 to the end of “Computer Applications” so str becomes “Computer ApplicationslO”.
“UnderstandingComputer ApplicationslO” to the console.

ICSE Class 10 Computer Applications Sample Question Paper 16 with Answers

(v) Predict output
boolean p;
p = (“BLUEJ”.length() > “bluej”.length()) ? true: false;
Answer:
(v) false
Explanation:
Both “BLUEJ” and “bluej” have the same length 5. So, condition of ternary operator is false and false is assigned to boolean variable p.

(vi) Output of the following code is :
String arr[]= {“DELHI”, “CHENNAI”, “MUMBAI”, “LUCKNOW”, “JAIPUR”};
System.out.println(arr[0].length() > arr[3].length());
System.out.print(arr[4].substring(0,3));
(a) false JAI
(b) false
(c) JAI
(d) JA
Answer:
(a) false
JAI
Explanation:
As length of the string “DELHI” is less than that of “LUCKNOW” so first output is false. arr[4]. substring^,3) will return the substring of “JAIPUR” starting at index 0 till index 2 (i.e. 3-1 = 2).

ICSE Class 10 Computer Applications Sample Question Paper 16 with Answers

(vii) Predict output
String strl = “Information Technology”;
String str2 = “information technology”;
boolean p = strl. equalsIgnoreCase(str2);
System.out.println(“The result is ” + p);
(a) “Information Technology”
(b) “information technology”
(c) true
(d) false
Answer:
The result is true
Explanation:
strl.equalsIgnoreCase(str2) will do a case insensitive comparison of strl and str2. As both strings contain the same characters if we ignore the case so it returns true which is stored in boolean variable p.

(viii) Which of these access specifiers must be used for main() method?
(a) private
(b) public
(c) protected
(d) none of the mentioned
Answer:
(b) public
Explanation:
main() method must be specified public as it called by Java run time system, outside of the program. If no access specifier is used then by default member is public within its own package and cannot be accessed by Java run time system.

ICSE Class 10 Computer Applications Sample Question Paper 16 with Answers

(ix) Which of these is used as a default for a member of a class if no access specifier is used for it?
(a) private
(b) public
(c) public, within its own package
(d) protected
Answer:
(a) private
Explanation:
When we pass an argument by call-by-value a copy of argument is made into the formal parameter of the subroutine and changes made on parameters of subroutine have no effect on original argument, they remain the same.

(x) Given sl=” computer” , s2=”Computer” , The statements
(i) sl.equalsIgnoreCase(s2) and
(ii) sl.equals(s2)will return
(a) True,true
(b) False,false
(c) true,false
(d) false,true
Answer:
(c) true, false
Explanation:
sl.equalsIgnoreCase(s2) compares the two strings without considering the case, hence returns true. sl.equals(s2) compares the two strings considering the case, hence returns false. So output is true, false:

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.

ICSE Class 10 Computer Applications Sample Question Paper 16 with Answers

Question 2.
Define a class to accept a sentence and display those words that begin with a vowel. Sample Input: A quick brown fox jumps over a lazy dog.
Sample Output: A over a
Answer:

import java.util. Scanner;
public class Vowelwords
{
public static void main(String[] args)
{
String sen="",word=""; int i;
char ch;
Scanner sc=new Scanner(System.in);
sen=sc.nextLine();
for(i=0;i< sen.length();i++)
{
if (sen. charAt(i)!='')
{
word+=sen.charAt(i);
}
else
{
ch=word. charAt(O);
if (ch—'a' I I ch='e' I I ch='i' I I ch—'o' I I ch=='u')
System.out.println(word);
word="";
}
}
}
}

ICSE Class 10 Computer Applications Sample Question Paper 16 with Answers

Question 3.
Write a program that reads a long number, counts and displays the occurrences of each digit in it.
Answer:

import java.util.Scanner;
public class NumberOccurance
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
long num = in.nextLong();
int dCount[] = new int[10];
while (num != 0)
{
int d = (int) (num % 10);
dCount[d] = dCount[d] + 1;
num /= 10;
}
System.out.println("Digit\tOccurence");
for (int i = 0; i < 10; i++)
{
if (dCountfi] != 0)
{
System.out.println(i + "\t" + dCount[i]);
}
}
}
}

ICSE Class 10 Computer Applications Sample Question Paper 16 with Answers

Question 4.
Write a program in Java to accept a word/a String and display the new string after removing all the vowels present in it.
Sample Input: COMPUTER APPLICATIONS
Sample Output: CMPTR PPLCTNS
Answer:

import java.util.Scanner;
public class VowelRemoval
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter a word or sentence:");
String str = in.nextLine();
int len = str.length();
String newStr = "";
for (int i = 0; i < len; i++)
{
char ch = Character.toUpperCase(str.charAt(i));
if (ch = 'A' I I ch == 'E' I I ch = T I I ch = 'O’ I I ch = 'U')
{
continue;
}
newStr = newStr + ch;
}
System.out.println("String with vowels removed");
System.out.println(newStr);
}
}

ICSE Class 10 Computer Applications Sample Question Paper 16 with Answers

Question 5.
Define a class in Java to enter a String/Sentence and display the longest word and the length of the longest word present in the String.
Sample Input: “Sir Garry Sobers is one of the legends in IntemationalCricket”
Sample Output: The longest word: IntemationalCricket: The length of the word: 20
Answer:

import java.util.Scanner;
public class LongestWord
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter a word or sentence:");
String str = in.nextLine();
str += " //Add space at end of
string String word = ""; IWord = "";
int len = str.length();
for (int i = 0; i < len; i++) { char ch = str.charAt(i); if (ch =='') { if (word.length() >
IWord.length()) IWord =
word;
word = "";
}
else
{
word += ch;
}
}
System.out.println("The longest word: " + IWord + ": The length of the word: " + IWord. lengthQ);
}
}

ICSE Class 10 Computer Applications Sample Question Paper 16 with Answers

Question 6.
Define a class in Java to store 20 numbers in a Single Dimensional Array. Display the numbers which are composite.
Sample Input:

n[0] n[l] n[2] n[3] n[4] n[5] n[16] n[l 7] n[18] n[19]
45 65 77 71 90 67 82 19 31 52

Sample Output: 45,65,77,90,82,52
Answer:

import java.util.Scanner;
public class CompositeNumbers
{
public static void main(String args[])
{
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.nextlnt();
}
System.out.println("Composite Numbers:"); for (int i = 0; i < arr.length; i++)
{
int c = 0;
for (int j = 1; j <= arr[i]; j++)
{
if (arr[i] % j — 0)
{
C++;
}
}
if (c != 2)
System.out.print(arr[i] + ", ");
}
}
}

ICSE Class 10 Computer Applications Sample Question Paper 16 with Answers

Question 7.
Define a class in Java to accept a word and display the ASCII code of each character of the word.
Sample Input: BLUEJ
Sample Output:
ASCII of B = 66
ASCII of L = 76
ASCII of U = 85
ASCII of E = 69
ASCII of J = 74
Answer:

import java.util.Scanner;
public class ASCIICode
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter a word:");
String word = in.nextLine();
int len = word.length();
for (int i = 0; i < len; i++)
{
char ch = word.charAt(i);
System.out.println("ASCII of " + ch
+ " = " + (int)ch);
}
}
}
ICSE Class 10 Computer Applications Question Papers with Answers

Leave a Comment