ICSE Computer Applications Question Paper 2017 Solved for Class 10

ICSE Computer Applications Previous Year Question Paper 2017 Solved for Class 10

General Instructions:

  • Answers to this Paper must be written on the paper provided separately.
  • You will not be allowed to write during the first 15 minutes.
  • This time is to be spent in reading the question paper.
  • The time given at the head of this paper is the time allowed for writing the answers.
  • This Paper is divided into two Sections.
  • Attempt all questions from Section A and any four questions from Section B.
  • The intended marks for questions or parts of questions are given in brackets [ ].

Section-A [40 Marks]
(Attempt ALL Questions)

Question 1.
(a) What is inheritance ? [2]
(b) Name the operators listed below r [2]
(0 <
(it) + +
(iii) &&
(iv) ? :
(c) State the number of bytes occupied by char and int data types. [2]
(d) Write one difference between / and % operator. [2]
(e) String x[ ] = {“SAMSUNG”, “NOKIA”, “SONY”, “MICROMAX”, “BLACKBERRY”}; [2]
Give the output of the following statements :
(i) System.out.prindn(x[1]);
(ii) System.out.println(x[3].length{ )); ,
Answers:
(a) 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) (i) Comparison operator
(ii) Unary operator
(iii) Logical operator
(iv) Ternary operator

(c) The char data occupies two bytes whereas int data type occupies four bytes.
(d) The / operator is used for division whereas % operator is used to find the remainder.
(e) (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.
(b) What are the two ways of invoking functions? [2]
(c) State the data type and value of res after the following is executed: [2]
char ch = ‘t’;
res=Character. toUpperCase(ch);
(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);

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

Answers:
(a) (i) import
(ii) Array
(b) By Value and By Reference
(c) int type and value is 84.
(d) 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) 75 F

Question 3.
(a) Write a Java expression for the following : [2]
ax5 + bx3 + c
(b) What is the value of xl if x=5 ? [2]
x1 = + +x – X+ + + –x
(c) Why is an object called an instance of a class ? [2]
(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);
(e) Differentiate between constructor and function. [2]

(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”);

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

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

(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.

(f) What is the difference between the Scanner class functions nextQ and nextLine()? [2]

Answers:
(a) a.Math.pow(x,5) + b.Math.pow(x,3) +c;
(b) 6
(c) 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) int i =1;
int d = 5;
for(i = 1; i < = 5; i+ +) {
d = d*2;
System.out.println(d);
}

(e) 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) 0
Today i Holiday
(g) r1 = 5.83 .
r2 = 4.0
(h) Result 1 = 26100200
Result 2 = 126
(i) (i) Once
(ii) WIN
WIN

(j)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.

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

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 :
ICSE Computer Applications Question Paper 2017 Solved for Class 10 - 1
A surcharge of 2.5% charged if the number of units consumed is above 300 units.
ICSE Computer Applications Question Paper 2017 Solved for Class 10 - 2
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.readLine( );
System.out.print( “Number of units consumed = “);
String un = reader. readLine( );
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(“Naine of the customer:” +n);
System.out.println(“Number of units consumed:” +units);
System.out.println(“Bill amount:” + bill);
}
public static void main(String argsQ) throws IO
Exception { ElectricBill eb = new ElectricBill( );
eb. accept!);
eb.calculate();
}
}

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 = l + l+ 2 + 4 = 8
Product of the digits = 1×1 x2x4 = 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 ft 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 + x2 – 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 argsQ) throws IOException {
InputStreamReader reader = new InputStreamReader(System.in);
BufferedReader input = new BufferedReader(reader);
System.out.println(“l-Sum of Series:”);
System.out.println(“2-Display Special Series:”);
System.out.println(“Enter your choice:”);
String n1 = input.readLine( );
int ch = Integer.parselnt(nl);
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;
}
}
}

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 args[ ]) {
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.nextlntO;
}
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:
str = “success”
ch = ‘s’ .
Output:
number of s present is = 3

(ii) void check(String si) – to display only vowels from string si, after converting it to lower case.
Example:
Input:
s1 = “computer”
Output:
o u e
Answer:
class CharacterVowel {
public void checkering 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<s1.length();i+ +) {
ch = s1.charAt(i);
if(Character.isUpperCase(ch))
chr = Character. toLo werCase(ch);
if((s1 .charAt(i)==’a’) 11 (s1 .charAt(i) = ‘u’) | j(s1 .charAt(i) = = ‘o’)| | (s1 .charAt(i)==’i’) 11 (s1 .charAt(i) = = ‘e’))
System.out.println(s1 .charAt(i));
}
}
}

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.nextlnt( );
String names[ ] = new String[n];
Scanner s1 = new Scanner(System.in);
System.out.println(“Enter all words:”);
for(int i = 0; i < n; i+ +) {
names[i] = s1.nextLine[( );
}
for (int i = 0; i < n; i+ +){
for (int j = i + 1; j < n;j++){
if (names[i].compareTo(namesG]) < 0) {
temp = names [i];
names[i] = namesG];
names[j] = temp;
}
}
}
System.out.print(“Words in Descending Order:”);
for (int i = 0;i<n-l;i++){
System.out.print(names[i] + “,”);
}
System.out.print(names[n – 1]);
}
}

ICSE Class 10 Computer Applications Previous Years Question Papers

Leave a Comment