Solving ICSE Class 10 Computer Applications Previous Year Question Papers ICSE Class 10 Computer Applications Question Paper 2017 is the best way to boost your preparation for the board exams.

ICSE Class 10 Computer Applications Question Paper 2017 Solved

Section – A (40 Marks)
(Attempt all Questions)

Question 1.
(a) What is inheritance ? [2]
Answer:
Inheritance in java is a mechanism in which one object acquires all the properties and behaviors of parent object. The idea behind inheritance in java is that you can create new classes that are built upon existing classes. When you inherit from an existing class, you can reuse methods and fields of parent class, and you can add new methods and fields also.

(b) Name the operators listed below: [2]
(i) <
(ii) ++
(iii) &&
(iv) ? :
Answer:
(i) Comparison operator
(ii) Unary operator
(iii) Logical operator
(iv) Ternary operator

ICSE 2017 Computer Applications Question Paper Solved for Class 10

(c) State the number of bytes occupied by char and int data types. [2]
Answer:
The char data occupies two bytes whereas int data type occupies four bytes.

(d) Write one difference between / and % operator. [2]
Answer:
The / operator is used for division whereas % operator is used to find the remainder.

(e) String x[J = {“SAMSUNG”, “NOKIA”, “SONY”, “MICROMAX”, “BLACKBERRY”}; [2]
Give the output of the following statements:
(i) System.out.println(x[1]);
(ii) System.out.println(x[3].length());
Answer:
(i) NOKIA
(ii) 8

Question 2.
(a) Name the following: [2]
(i) A keyword used to call a package in the program.
(ii) Any one reference data type.
Answer:
(i) import
(ii) Array

(b) What are the two ways of invoking functions? [2]
Answer:
By Value and By Reference

(c) State the data type and value of res after the following is executed: [2]
char ch = ‘t’;
res = Character.toUpperCase(ch);
Answer:
int type and value is 84.

(d) Give the output of the following program segment and also mention the number of times the loop is executed: [2]
int a,b;
for (a = 6, b = 4; a <= 24; a = a + 6)
{
if (a%b == 0)
break;
}
System.out.println(a);
Answer:
Output is 12. Twice.
In the loop : for (a = 6, b = 4; a <= 24; a = a + 6), the value of a will be incrementing as 6,24 and upon incrementing the value to 42, the loop will terminate. Accordingly the loop has to execute two times.
But within the loop there is a condition : if(a%b =0) break;
This means when remainder on dividing a by b comes out to be 0 (at 24/4 = 0), the condition breaks and from the above it is clear that value of a is incremented from 6 to 24 when the loop executes second time.

(e) Write the output: [2]
char ch= ‘F’;
int m = ch;
m = m + 5;
System.out.println(m + ” ” + ch);
Answer:
75 F

ICSE 2017 Computer Applications Question Paper Solved for Class 10

Question 3.
(a) Write a Java expression for the following: [2]
ax5 + bx3 + c
Answer:
a.Math.pow(x,5) + b.Math.pow(x,3) +c;

(b) What is the value of x1 if x=5 ? [2]
x1 = ++ x – x +++ – – x
Answer:
6

(c) Why is an object called an instance of a class? [2]
Answer:
An object is a software bundle of related state and behavior. A class is a blueprint or prototype from which objects are created. An instance is a single and unique unit of a class.

(d) Convert following do-while loop into for loop. [2]
int i = 1;
int d = 5;
do {
d = d*2;
System.out.println(d);
i++;
} while (i <= 5);
Answer:
int i = 1;
int d = 5;
for(i = 1; i <= 5; i++) {
[2] d = d*2;
System.out.println(d);
}

(e) Differentiate between constructor and function. [2]
Answer:
Constructors must be named with the same name as the class name. They cannot return anything, even void (the object itself is the implicit return).
Functions must be declared to return something, although it can be void.

(f) Write the output for the following: [2]
String s = “Today is Test”;
System.out.println(s.indexOf(T));
System.out,println(s.substring(0, 7) + ” ” + “Holiday”);
Answer:
0
Today is Holiday

ICSE 2017 Computer Applications Question Paper Solved for Class 10

(g) What are the values stored in variables r1 and r2 [2]
(i) double r1 = Math.abs(Math.min(-2.83,-5.83));
(ii) double r2 = Math.sqrt(Math.floor( 16.3));
Answer:
r1 = 5.83
r2 = 4.0

(h) Give the output of the following code:
String A = “26”, B=”100″;
String D = A + B +”200″:
int x = Integer.parselnt(A);
int y = Integerparselnt(B);
int d = x+y:
System.out.println(“Result 1 = “+D);
System.out.prinln(“Result 2 = ”+d);
Answer:
Result 1 = 26100200
Result 2 = 126

(i) Analyze the given program segment and answer the following questions : [2]
for (int i = 3; i <= 4 ; i++) {
for (int j = 2; j < i ; j++) {
System.out.print(” “); }
System.out.println(“WIN”); }
(i) How many times does the inner loop execute?
(ii) Write the output of the program segment.
Answer:
(i) Once
(ii) WIN
WIN

(j) What is the difference between the Scanner class functions next() and nextLine()? [2]
Answer:
next() can read the input only till the space. It cannot read two words separated by space.
Also, next() places the cursor in the same line after reading the input.
nextLine() reads input including space between the words (that is, it reads till the end of line \n). Once the input is read, nextLine() positions the cursor in the next line.

ICSE 2017 Computer Applications Question Paper Solved for Class 10

[Section – B (60 Marks)]
Attempt any four questions from this Section.

Question 4.
Define a class ElectricBill with the following specifications: [15]
class : ElectricBill
Instance variables /data member :
String n – to store the name of the customer
int units – to store the number of units consumed
double bill – to store the amount to be paid
Member methods:
void accept ( ) – to accept the name of the customer and number of units consumed
void calculate ( ) – to calculate the bill as per the following tariff:

Number of units Rate per unit
First 100 units Rs. 2.00
Next 200 units Rs. 3.00
Above 300 units Rs. 5.00

A surcharge of 2.5% charged if the number of units consumed is above 300 units.
void print ( ) – to print the details as follows:
Name of the customer: ……………………
Number of units consumed: ……………………
Bill amount: ……………………
Write a main method to create an object of the class and call the above member methods.
Answer:

import java.io.*;
class ElectricBill {
String n;
int units;
double bill;
void accept() throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Name of the customer = ");
n = reader.readLineQ;
System.out.print("Number of units consumed = ");
String un = reader.readLineQ;
units=Integer.parselnt(un);
}
void calculate() {
if(units <= 100)
bill = 2.00*units;
if(units <= 300) bill = 3.00*units; if (units > 300)
bill = 5.00*units;
}
void print(){
System.out.println("Name of the customer:" + n);
System.out.println("Number of units consumed:" + units);
System.out.println("Bill amount:" + bill);
}
public static void main(String aigs[]) throws IOException {
ElectricBill eb = new ElectricBill();
eb.accept();
eb.calculate();
}
}

ICSE 2017 Computer Applications Question Paper Solved for Class 10

Question 5.
Write a program to accept a number and check and display whether it is a spy number or not. (A number is spy if the sum of its digits equals the product of its digits.) [15]
Example: consider the number 1124, Sum of the digits = 1 + 1 + 2 + 4 = 8
Product of the digits = 1 × 1 × 2 × 4 = 8
Answer:

class Spy {
public static void main(int n) {
int sum = 0;
int multiple = 1;
int a;
int p = n;
// a stores each digit extracted and p creates a backup of input.
while(n != 0) {
a = n% 10;
sum = sum + a;
multiple = multiple * a;
n = n/10;
}
System.out.println("The sum of" +p +" is "+sum);
System.out.println("The product of "+p +" is "+multiple);
if(sum == multiple) {
System.out.println("Aha, " + "It is a Spy Number Where Sum = Product");
}
else {
System.out.println(" It is NOT a Spy Number Where Sum # Product");
}
}
}

Question 6.
Using switch statement, write a menu driven program for the following: [15]
(i) To find and display the sum of the series given below:
S = x1 – x2 + x3 – x4 + x5 ……………………. – x20
(where x = 2)
(ii) To display the following series :
1 11 111 1111 11111
For an incorrect option, an appropriate error message should be displayed.
Answer:

import java.io.*;
class SwitchStatement {
public static void main(String args[]) throws IOException {
InputStreamReader reader = new InputStream Reader(System.in);
BufferedReader input = new BufferedReader (reader);
System.out.println("1 -Sum of Series:");
System.out.println("2-Display Special Series:");
System.out.println("Enter your choice:");
String n1 = input.readLine();
int ch = Integer.parselnt(n1);
System.out.println("Enter Number of Terms :");
String t = input.readLine();
int n = Integer.parselnt(t);
switch (ch) {
case 1:
int sign = - 1;
double term = 0;
double sum - 0;
int x = 2;
System.out.println("Value of x: " +x);
System.out.println("Number of terms: " +n);
sum += x; // First term added here,
for (int i = 2; i <= n; i++) {
term = sign * Math.pow(x, i);
sum += term;
sign *= - 1;
}
System.out.println("Sum of Series :" +sum);
break;
case 2 :
int num;
System.out.println("Enter the number of terms: ");
String tm = input.readLine();
num = Integer.parselnt(tm);
int s = 0, c;
for (c = 1; c <= num; c++) {
s = s * 10 + 1;
System.out.print(s + " ");
}
break;
}
}
}

ICSE 2017 Computer Applications Question Paper Solved for Class 10

Question 7.
Write a program to input integer elements into an array of size 20 and perform the following operations: [15]
(i) Display largest number from the array.
(ii) Display smallest number from the array.
(iii) Display sum of all the elements of the array.
Answer:

import java.util.Scanner;
class LargeSmallSum {
public static void main(String aigs[ ]) {
int n;
int max, min, sum = 0;
int i, j;
Scanner s = new Scanner(System.in);
System.out.print("Enter no. of elements you want in array:");
n = s.nextlnt();
int a[] = new int[n];
System.out.println("Enter all the elements:");
for (i = 0; i < n; i++) {
a[i] = s.nextlnt();
}
max = a[0];
min = a[0];
for(i = 0; i < n ; i++) { if(a[i] > max) {
max = a[i];
}
if (a[i] < min) {
min = a[i];
}
}
System.out.println("Maximum Number is:"+max);
System.out.println("Smallest Number is:" +min);
for(i = 0; i < n; i++) {
sum = sum + a[i];
}
System.out.println("Sum of the Numbers is:" +sum);
}
}

Question 8.
Design a class to overload a function check ( ) as follows : [15]
(i) void check (String str, char ch) – to find and print the frequency of a character in a string.

Example:

Input: Output:
str= “success” number of s present is = 3
Ch = ‘s’

(ii) void check(String s1) – to display only vowels from string si, after converting it to lower case.
Example:

Input: Output:
str= “computer” O u e

class CharacterVowel {
Answer:

public void check(String str, char ch) {
int c = 0, code, i, s;
str = str.toLowerCase();
int len = str.length();
for (code = 97; code < 122; code++) {
c = 0;
for (i = 0; i < len; i++) {
ch = str.charAt(i);
s = (int) ch;
if(s = code)
c = c + 1;
}
ch = (char)code;
if(c != 0)
System.out.println("Frequency of "+ch+ "is" + c);
}
}
public void check(String si) {
int i;
char ch=0,
chr=0;
for(i=0;i<sl.length();i++) {
ch = sl.charAt(i);
if(Character.isUpperCase(ch))
chr Character.toLowerCase(ch);
if((s1 .charAt(i)=='a')||(s1 .charAt(i)=='u')||(s1. charAt(i)=='o')||(s1 .charAt(i)=='i')||
(s1.charAt(i)=='e')) '
System.out.println(s1.charAt(i));
}
}
}

ICSE 2017 Computer Applications Question Paper Solved for Class 10

Question 9.
Write a program to input forty words in an array. Arrange these words in descending order of alphabets, using selection sort technique. Print the sorted array. [15]
Answer:

import java.util.Scanner; class Descending {
public static void main(String args[ ]) {
int n;
String temp;
Scanner s = new Scanner(System.in);
System.out.print("Enter number of words you want to enter:");
n = s.nextInt();
String names[] = new String[n];
Scanner si = new Scanner(System.in);
System.out.println("Enter all words:");
for(int i = 0; i < n; i++) {
names[i] = sl.nextLine();
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (names[i].compareTo(names[j]) < 0) {
temp = names[i];
names[i] = names[j];
names[j] = temp;
}
}
}
System.out.print("Words in Descending Order:");
for (int i = 0; i < n -1; i++) {
System.out.print(names[i] + ",");
}
System.out.print(names[n - 1]);
}
}