You are on page 1of 123

ICSE Computer Applications Previous Year Question

Paper 2019 Solved for Class 10

General Instructions :

 Answers to this Paper must he 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) Name any two basic principles of Object-oriented
Programming.
(b) Write a difference between unary and binary
operator.
(c) Name the keyword which :
(i) indicates that a method has no return type.
(ii) makes the variable as a class variable.
(d) Write the memory capacity (storage size) of short
and float data type in bytes.
(e) Identify and name the following tokens :
(i) public
(ii) ‘a’
(iii) ==
(iv) {}
Solution.
(a) Abstraction and encapsulation are the basic
principles of Object-oriented Programming.
(b)

Unary Operators

(i) The operators which act upon a single operand (i) The op

are called unary operators. their acti

(ii) They are pre-increment and post increment (+ +) (ii) They


operators

(c)
(i) void
(ii) static

(d) (i) short: 2 bytes


(ii) float: 4 bytes

(e) (i) keyword


(ii) literal
(iii) operator
(iv) separator

Question 2.
(a) Differentiate between if else if and switch-case
statements. [2]
(b) Give the output of the following code : [2]
String P = “20”, Q = “19”,
int a = Integer .parselnt(P);
int b = Integer. valueOf(Q);
System.out.println(a+””+b);
(c) What are the various types of errors in Java ? [2]
(d) State the data type and value of res after the
following is executed : [2]
char ch = ‘9’;
res = Character. isDigit(ch) ;
(e) What is the difference between the linear search
and the binary search technique? [2]
Solution.
(a)

if else if

(i) It evaluates integer, character, pointer or floating-


(i) It eval
point type or boolean type.

(ii) Which statement will be executed depend upon (ii) Which

the output of the expression inside if statement. user.

(b) 2019
(c) Syntax error, Runtime error, Logical error
(d) boolean
True

(e)

Linear Search

(i) Linear search works both for sorted and unsorted (i) Binary

data. ascendin

(ii) Linear search begins at the start of an array i.e. (ii) This t

at 0th position. and the d

Question 3.
(a) Write a Java expression for the following : [2]
|x2+2xy|
(b) Write the return data type of the following
functions : [2]
(i) startsWith( )
(ii) random( )
(r) If the value of basic=1500, what will be the value
of tax after the following statement is executed? [2]
tax = basic > 1200 ? 200 : 100;
id) Give the output of following code and mention
how many times the loop will execute ? [2]
int i;
for(i=5; i> =l;i~)
{
if(i%2 ==1)
continue;
System.out.print(i+ ”
}
(e) State a difference between call by value and call
by reference. [2]
(f) Give the output of the following: [2]
Math.sqrt(Math.max(9, 16))
(g) Write the output for the following: [2]
String s1 = “phoenix”; String s2 =”island”;
System.out.prindn (s1.substring(0).concat
(s2.substring(2)));
System.out.println(s2.toUpperCase( ));
(h) Evaluate the following expression if the value
ofx=2,y=3 and z=1. [2]
v=x+–z+y+ + +y
(i) String x[ ] = {“Artificial intelligence”, “IOT”,
“Machine learning”, “Big data”}; [2]
Give the output of the following statements:
(i) System.out.prindn(x[3]);
(ii) System.out.prindn(x.length);
(j) What is meant by a package? Give an example.
[2]
Solution.
(a) Math.abs((x * x) + (2 * x * y);
(b) (i) boolean
(ii) double
(c) 200
(d) 4 2
Loop will execute 5 times.

(e)

Call by Value
(i) In call by value the method creates its new set of (i) In call

variables (formal parameters) to copy the value of paramete

actual parameters and works with them. of variab

(ii) Any change made in the formal parameter is not (ii) Any c

reflected in the actual parameter. always re

(iii) Refer
(iii) Primitive data types are passed by call by value.
passed b

(f) 4.0
(g) phoenix land
ISLAND

(h) = 2 + 0 + 3 + 4
(i) (i) Big data
(ii) 4
(j) A package is an organized collection of classes
which is included in the program as per
the requirement of the program. For example java.io
package is included for input and output operations
in a program.

Section -B [60 Marks]


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 so that the logic of
the program is clearly depicted.
Flow-Charts and Algorithms are not required.

Question 4.
Design a class name ShowRoom with the following
description :
Instance variables/ Data members :
String name – To store the name of the customer
long mobno – To store the mobile number of the
customer
double cost – To store the cost of the items
purchased
double dis – To store the discount amount
double amount – To store the amount to be paid
after discount
Member methods: –
ShowRoom() – default constructor to initialize data
members
void input() – To input customer name, mobile
number, cost
void calculate() – To calculate discount on the cost
of purchased items, based on following criteria

Cost

Less than or equal to ₹ 10000

More than ₹ 10000 and less than or equal to ₹ 20000

More than ₹ 20000 and less than or equal to ₹ 35000


More than ₹ 35000

void display() – To display customer name, mobile


number, amount to be paid after discount
Write a main method to create an object of the class
and call the above member methods.
Solution.
import java.io.*;
import java.util.*;
class ShowRoom {
String name;
long mobno;
double cost;
double dis;
double amount;
ShowRoom( ) {
name = ” “;
mobno =0;
cost = 0;
dis = 0;
amount = 0;
}
void input( ) {
Scanner sc = new Scanner(System.in);
System.out.println(“EnterName:”);
name = sc.nextLine( );
System.out.println(“Enter Mobile number:”);
mobno = sc.nextLong( );
System.out.println(“Enter cost:”);
cost = sc.nextDouble( );
}
void calculate( ) {
if (cost <= 10000){
dis cost*5/100;
amount = cost – dis;
}
else
if (cost > 10000 && cost < = 20000){
dis = cost* 10/100;
amount cost – dis;
}
else
if (cost > 20000 && cost < = 35000){
dis = cost* 15/100;
amount = cost – dis;
}
else
if (cost > 35000){
dis = cost*20/100;
amount = cost – dis;
}
}
void display( ) {
System.out.println(“Name::” +name);
System.out.println(“Mobile No.::” +mobno);
System.out.println(“Amount::” +amount);
}
public static void main(String args( )) {
ShowRoom ob = new ShowRoom( );
ob.input( );
ob.calculate( );
ob.display( );
}
}

Question 5.
Using the switch-case statement, write a menu
driven program to do the following : [15]
(a) To generate and print Letters from A to Z and
their Unicode Letters Unicode

(b) Display the following pattern using iteration


(looping) statement: 1
Solution.
import java.io.*;
import java.util.*;
class SwitchCase {
public static void main(String args[ ]) {
Scanner sc = new Scanner (System.in);
System.out.println(” 1. Enter 1 for Unicode:”);
System.out.prindn(” 2. Enter 2 for Pattern:”);
System.out.println(“Enter your choice:”);
int choice sc.nextlntO;
switch(choice){
case 1:
char ch;
System.out.println( “Letters \t Unicode”);
for (ch = ‘A’; ch < = ‘Z’; ch+ +) {
System.out.println(ch +”\t” + (int)ch);
}
break;
case 2:
int i, j;
for (i = 1; i < = 5; i+ +) {
for (j = 1; j < = i; j + +)
{
System.out.print(j + “”);.
}
System.out.printlnO;
}
break;
default:
System.out.println(“Wrong choice entered:”);
}
}
}

Question 6.
Write a program to input 15 integer elements in an
array and sort them in ascending order using the
bubble sort technique. [15]
Solution.
import java.io.*;
import java.util’*;
class AscendingOrder {
public static void main(String args[]) {
int i, j, temp;
Scanner sc = new Scanner(System.in);
int arr[] = new int[15];
System.out.println(“Enter 15 integers:”);
for (i = 0; i < = 15; i+ +) {
arr[i] = sc.nextlntO;
for(i = 0; i < 14; i++){
for(j = 0; j < 14 -i; j + +){
if(arr[j] > arr[j + 1]){
temp = arr[j];
arr[j] = arr [j + 1];
arr[j + 1] = temp;
}
}
}
System.out.println(“Elements in ascending order
are::”);
for (i = 0; i < 15; i+ +) {
System.out.println(arr[i]);
}
}
}
}

Question 7.
Design a class to overload a function series() as
follows: [15]
(a) void series (int x, int n) – To display the sum of
the series given below:
x1 + x2 + x3 + ……………. xn terms
(b) void series (int p) – To display the following
series:
0, 7, 26, 63 p terms.
(c) void series () – To display the sum of the series
given below:

Solution.
import java.io.*;
import java.util.*;
class OverloadSeries {
void series( int x, int n) {
int i; .
double a;
double sum = 0;
for (i = 1; i < = n; i++) {
a = Math.pow(x, i);
sum = sum + a;
}
System.out.prindn(“Sum::” +sum)r
}
void series(int p) {
int i;
for (i = 1; i < = p; i++) {
System.out.prindn((i * i * i) – 1 + ” “);
}
}
void series() {
double i;
double s = 0;
for (i =-2; i < = 10; i+ +) {
s = s + 1/i;
}
System.out.println(“Sum:” +s);
}
}

Question 8.
Write a program to input a sentence and convert it
into uppercase and count and display the total
number of words starting with a letter ‘A’. [15]
Example:
Sample Input: ADVANCEMENT AND APPLICATION
OF INFORMATION TECHNOLOGY ARE EVER
CHANGING.
Sample Output : Total number of words starting with
letter A’ = 4.
Solution.
import java.io.*;
import java.util.*;
class UpperCount {
public static void main(String args[ ]) {
int i, a;
Scanner sc = new Scanner(System.in);
String str, str1, str2;
System.out.prindn(“Enter sentence::”);
str = sc.nextLine();
strl = str.toUpperCaseO; ‘
str2 = “” + strl;
a = 0; ,
for (i = 0; i < = str2.1ength(); i+ +) {
if(str2.charAt(i) == ‘ ‘)
if(str2.charAt(i + 1) == ‘A’);
a+ +;
}
System.out.println(“Total number of words starting
with letter ‘A’::” +a);
}
}

Question 9.
A tech number has even number of digits. If the
number is split in two equal halves, then the square
of sum of these halves is equal to the number itself.
Write a program to generate and print all four digit
tech numbers. [15]
Example :
Consider the number 3025
Square of sum of the halves of 3025 = (30+25)2
= (55)2
= 3025 is a tech number.
Solution.
import java.io.*;
import java.util.*;
class TechNumber {
public static void main(String args[ ]) {
int i, a, b, sum;
String n;
System.out.println(“Four Digits Tech Numbers
are::”);
for(i = 1000; i < 1000; i+ +) {
n = i +””;
a = lnteger,parselnt(n.substring(0, 2));
b = Integer.parselnt(n.substring(2));
sum = (int)Math.pow((a + b), 2);
if (sum == i)
System.out.println(i);
}
}
}

ICSE Computer Applications Question Paper 2018 Solved for Class 10

October 19, 2019 by Prasanna

ICSE Computer Applications Previous Year Question


Paper 2018 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) Define abstraction.
(b) Differentiate between searching and sorting.
(c) Write a difference between the functions
isUpperCase( ) and toUpperCase( ).
(d) How are private members of a class different
from public members ?
(e) Classify the following as primitive or non-primitive
data types :
(i) char
(ii) arrays
(iii) int
(iv) classes
Solution:
(a) Abstraction is a process of hiding the
implementation details and showing only
functionality to the user.
(b) Searching is a technique which is used to search
a particular element in an array or string. Sorting is a
technique which is used to rearrange the elements
of an array or string in a particular order either
ascending or descending.
(c) The isUpperCase( ) method is used to check
whether the given character is in upper case or not.
It returns Boolean data type.
The toUpperCase( ) method is used to convert a
character or string into upper case. It returns char or
String type. •
(d) Scope of the private members is within the class
whereas scope of the public members is global.
(e) (i) char is primitive data type.
(ii) arrays are non-primitive data type.
(iii) int is primitive data type.
(iv) classes are non-primitive data type.

Question 2.
(a) (i) int res = ‘A’; [2]
What is the value of res ?
(ii) Name the package that contains wrapper
classes.
(b) State the difference between while and do while
loop. [2]
(r) System.out.print(“BEST”); |2]
System.out.println(“OF LUCK”);
Choose the correct option for the output of the
above statements
(i) BEST OF LUCK
(ii) BEST
OF LUCK
(d) Write the prototype of a function check which
takes an integer as an argument and returns a
character. [2]
(e) Write the return data type of the following
function. [2]
(i) endsWith( )
(ii) log( )
Solution:
(a) (i) Value of res is 65.
(ii) Java.lang
(b)

(c) (i) BEST OF LUCK is the correct option.


(c) char check(int x)
(e) (i) Boolean
(ii) double

Question 3.
(a) Write a Java expression for the following :

(b) What is the value of y after evaluating the


expression given below ?
y + = + +y+y–l –y; when int y=8
(c) Give the output of the following : [2]
(i) Math.floor (- 4.7)
(ii) Math.ceil(3.4) + Math.pow(2,3)
(d) Write two characteristics of a constructor. [2]
(e) Write the output for the following : [2]
System.out.prindn(“Incredible” + “\n” + “world”);
(f) Convert the following if else if construct into
switch case [2]
if (var= = 1)
System.out .println(“good”);
else if(var= =2)
System.out.prindn(“better”);
else if(var= =3)
System.out.prindn( “best”);
else
System.out.prindn(“invalid”);
(g) Give the output of the following string functions :
[2]
(i) “ACHIEVEMENT” .replaceCE’, ‘A’)
(ii) “DEDICATE”. compareTo(“DEVOTE”)
(h) Consider the following String array and give the
output [2]
String arr[]= {“DELHI”, “CHENNAI”, “MUMBAI”,
“LUCKNOW”, “JAIPUR”};
System.out.println(arr[0] .length( )> arr[3] .length( );
System.out.print(arr[4] ,substring(0,3));

(i) Rewrite the following using ternary operator : [2]


if(bill > 10000)
discount = bill * 10.0/100;
else
discount = bill * 5.0/100;
(i) Give the output of the following program segment
and also mention how many times the loop is
executed : [2]
int i;
for (i = 5; i > 10; i + +)
System.out.printin(i);
System.out.println(i*4);
Solution:
(a) Math.sqrt * (3 * x + Math.pow(x, 2)) / (a + b);
(b) 8 + (9 + 9 + 7) = 8 + 25 =33
(c) (0 – 5.0 (it) 12.0
(d) (i) Constructor has the same name as of class.
(ii) Constructor gets invoked when an object is
created.
(e) Incredible
world
(f) switch ( ) {
case 1:
System.out .println( “good”);
break; .
case 2:
System.out .println( “better”);
break;
case 3:
System.out.println( “invalid”);
break;
}
(g) (i) ACHIAVAMANT
(ii) – 18
(h) false (at index 0, DELHI consists of 5 characters,
at index 3, LUCKNOW consists of 7 characters.
Therefore 5 > 7 is false)
JAI (at index 4, JAIPUR exists and extract its three
characters)
(i) discount = bill > 100 ? bill * 10.0 /100 : bill * 5.0
/100;
(j) 20. Loop will be executed for 0 times.
Section-B [60 Marks]
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 so that the logic of
the program is clearly depicted.
Flow-Charts and Algorithms are not required.

Question 4.
Design a class Railway Ticket with following
description : [15]
Instance variables/s data members :
String name : To store the name of the customer
String coach : To store the type of coach customer
wants to travel
long mobno : To store customer’s mobile number
int amt : To store basic amount of ticket
int totalamt : To store the amount to be paid after
updating the original amount

Member methods
void accept ( ) — To take input for name, coach,
mobile number and amount
void update ( )— To update the amount as per the
coach selected
Type of Coaches

First_ AC

Second_AC

Third _AC

sleeper

void display( ) — To display all details of a customer


such as name, coach, total amount and mobile
number.
Write a main method to create an object of the class
and call the above member methods.
Solution:
import java.io.*;
import java.util.Scanner; class RailwayTicket {
String name, coach;
long mobno;
int amt, totalamt;
void accept( ) throws IOException {
Scanner sc = new Scanner(System.in);
System.out.print(“Enter Passenger’s Name: “);
name = sc.next( );
System.out.print(“Enter Mobile Number:”);
mobno = sc.nextlnt( );
Systein.out.print(“Enter Coach
(FirstAC/SecondAC/ThirdAC/sleeper):”);
coach = sc.next( );
System.out.print(“Enter basic amount of ticket:”);
amt = sc.nexdnt( );
}
void update!) {
if (coach.equals(“First_AC”))
totalamt = amt + 700;
else
if (coach.equals(“Second_AC”))
totalamt = amt + 500; .
else
if (coach.equals!”Third_AC”))
totalamt = amt + 250;
else
totalamt = amt;
}
void display() {
System.out.println(“\n\n Name :” +name);
System.out.println(“Coach :” +coach);
System.out.prindn(”Total Amount:” +totalaint);
System.out.prindn(“Mobile No.:” +name);
}
public static void main (String args[ ]) throws
IOException {
RailwayTicket t = new RailwayTicket!);
t.accept();
t.update();
t.display();
}
}

Question 5.
Write a program to input a number and check and
print whether it is a Pronic number [15] or not.
(Pronic number is the number which is the product
of two consecutive integers)
Examples : 12 = 3 × 4 .
20 = 4 × 5
42 = 6 × 7
Solution:
import java.io.*;
import java.util. Scanner;
class Pronic]
public static void main(String argsQ) throws
IOException {
Scanner sc = new Scanner(System.in);
System.out.print(“Enter the number: “);
int n = sc.nextlnt();
int i = 0;
while(i * (i + 1) < n) {
i++;
}
if(i *(i + 1) = = n){
System.out.println(n + ” is a Pronic Number.”);
}
else {
System.out.prindn(n + ” is not a Pronic Number.”);
}
}
}

Question 6.
Write a program in Java to accept a string in lower
case and change the first letter of every word to
upper case. Display the new string. [15]
Sample input: we are in cyber world
Sample output : We Are In Cyber World
Solution:
import java.io.*;
import java.util.Scanner;
class ChangeLetter {
public static void main(String args[ ]) throws
IOException {
Scanner sc = new Scanner(System.in);
System.out.print(“Enter String in lowercase:”);
String str 1 = sc.next( );
strl = “” +strl;
String str2 = ” “:
for (int i = 0; i<strl.length( ); i+ +) {
if(strl ,charAt(i) = = “) {
str2 = str2 + ” +Character.
toUpperCase(strl.charAt(i+l));
i+ + ;
}.
else
str2= str2 + strl.charAt(i);
}
System.out.println(str2.trim( ));
}
}

Question 7.
Design a class to overload a function volume() as
follows : [15]
(i) double volume (double R) — with radius (R) as an
argument, returns the volume of sphere using the
formula.
V = 4/3 × 22/7 × R3
(ii) double volume (double H, double R) – with
height(H) and radius(R) as the arguments, returns
the volume of a cylinder using the formula.
V = 22/7 × R2 × H
(iii) double volume (double L, double B, double H) –
with length(L), breadth(B) and Height(H) as the
arguments, returns the volume of a cuboid using the
formula.
Solution:
class ShapesVolume {
public static double volume (double R) {
double V = 4.0 / 3, * 22.0 / 7 * Math.pow(R, 3);
return V;
}
public static double volume(double H, double R) {
double V = 22.0 / 7 * R * R * H ;
return V;
}
public static double volume (double L, double B,
double H) {
double V = L * B * H;
return V;
}
}

Question 8.
Write a menu driven program to display the pattern
as per user’s choice. [15]
For an incorrect option, an appropriate error
message should be displayed.
Solution:
import java.io.*;
import java.util.Scanner;
class Pattern {
public static void main(String args[]) throws
IOException {
Scanner sc = new Scanner(System.in);
System.out.println(“::::MENU::::”)
System.out.println(” 1. To display ABCD Pattern”);
System.out.print(” 2. To display Word Pattern”);
System.out.print(“Enter your choice:”);
int ch= sc.nextlnt();
switch(ch) {
case 1:
for (char i = ‘E’; i > = ‘A’; i- -){
for(char j = ‘A’;j <=i;j + +){
System.out.print(j);
}
System.out.prindn( );
}
break;
case 2:
String S = “BLUE”;
for (int i = 0; i < S.length(); i+ +) {
for(int j = 0; j < =i; j + +) {
System.out.print(S.charAt(i));
}
System.out.println();
}
break;
default:
System.out.println(“Invalid Input”);
break;
}
}
}

Question 9.
Write a program to accept name and total marks of
N number of students in two single subscript array
name[] and totalmarks[ ].   [15]
Calculate and print:
(i) The average of the total marks obtained by N
Number of students.
[average = (sum of total marks of all the students)/N]
(ii) Deviation of each student’s total marks with the
average.
[deviation = total marks of a student – average] ‘
Solution:
import java.io.*;
import java. util. Scanner;
class NameMarks {
public static void main(String argsO) throws
IOException {
Scanner sc = new Scanner(System.in);
System.out.print(“Enter number of students:”);
int N = sc.nextlnt( );
String named = new String[N];
int totalmarksG = new int[N];
double deviation[ ] = new double[N];
double sum = 0;
for (int i = 0; i < N; i+ +) {
System.out.print(“Enter Name of the Student:”);
name[i] = sc.next( );
System.out.print(“Enter Marks:”);
totalmarks[i] = sc.nextlntO;
sum = sum + totalmarks [i];
}
double average = sum / N;
System.out.println(“The average of the total marks of
” +N+” number of students:” +average);
for (int i = 0; i < N; i+ +) {
deviadon[i] = total marks (i] – average;
System.out.println(“Deviation of” + name[i] + “s
marks with the average:” +deviation[i]);
}
}
}

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 :

A surcharge of 2.5% charged if the number of units


consumed is above 300 units.

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:
oue
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 Computer Applications Previous Year Question


Paper 2016 Solved for Class 10

ICSE Paper 2016


COMPUTER APPLICATIONS

(Two Hours)
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) Define Encapsulation. [2]
(b) What are keywords ? Give an example. [2]
(c) Name any two library packages. [2]
(d) Name the type of error ( syntax, runtime or
logical error) in each case given below: [2]
(i) Math.sqrt (36 – 45)
(ii) int a;b;c;
(e) If int x [ ] = { 4, 3,7, 8, 9,10}; what are the values
of p and q ? [2]
(i) p = x.length
(ii) q = x[2] + x[5] * x[1]

Answer:
(a) Encapsulation: It is process of wrapping code
and data together into a single unit (called class).
(b) Keywords: Keywords are reserved words in
Java, which have a special meaning in the
language.
Example: if, void, int etc.

(c) (i) java.io
(ii) java.util

(d) (i) logical error


(ii) syntax error

(e) (i) Value of P will be 6.


(ii) q = x[2] + x[5] * x[1]
= 7 + 10 * 3
= 7 + 30 = 37
value of q is 37.

Question 2:
(a) State the difference between == operator and
equals ( ) method. [2]
(b) What are the types of casting shown by the
following examples: [2]
(i) char c = (char) 120;
(ii) int x = ‘t’;
(c) Differentiate between formal parameter and
actual parameter. [2]
(d) Write a function prototype of the following: [2]
A function PosChar which takes a string argument
and a character argument and returns an integer
value.
(e) Name any two types of access specifiers. [2]

Answer:
(a)

= = operator

It is a relational operator.

It checks for equality of primitive type of values. It chec

(b) (i) Explicit type conversion,


(ii) Implicit type conversion.

(c)
Formal parameter

They ar
They are variables define in function signature.

They receive value from actual parameter. T

(d) int PosChar (String str, char ch)

(e) Two types of access specifiers:


1. public
2. . private

Question 3:
(a) Give the output of the following string
functions: [2]
(i) “MISSISSIPPI”.indexOf(‘S’) +
“MISSISSIPPF”.lastIndexOf(‘I’)
(ii) “CABLE”.compareTo(“CADET”)
(b) Give the output of the following Math
functions: [2]
(i) Math.ceil(4.2)
(ii) Math.abs(-4)

(c) What is a parameterized constructor ? [2]

(d) Write down java expression for: [2]


T=A2+B2+C2−−−−−−−−−−−√
(e) Rewrite the following using ternary operator: [2]
if (x%2 == o)
System.out.print(“EVEN”);
else
System.out.print(“ODD”);

(f) Convert the following while loop to the


corresponding for loop: [2]
int m = 5, n = 10;
while (n>=1)
{
System.out.println(m*n);
n-;
}

(g) Write one difference between primitive data


types and composite data types. [2]
(h) Analyze the given program segment and answer
the following questions: [2]
(i) Write the output of the program segment.
(ii) How many times does the body of the loop gets
executed ?

(i) Give the output of the following expression: [2]


a+= a++ + ++a + – – a + a – – ; when a = 7

(j) Write the return type of the following library


functions: [2]
(i) isLetterOrDigit(char)
(ii) replace(char, char)

Answer:
(a) (i) 2 + 10 = 12
(ii) -3

(b) (i) 5.0
(ii) 4
(c) Parameterized Constructor: It is a constructor
which accepts parameters. When an object is
declared using parameterized constructor, the initial
values have to be passed as arguments to the
constructor.

(d) T = Math.sqrt (A*A + B*B + C*C);

(e) String k;
k = x%2 == 0 ? “EVEN” : “ODD”;
System.out.print(k);

(f) for (int m=5, n=10; n>=1; n – – )


{
System.out.println (m*n);
}

(g)

Primitive data types

They are predefined/inbuilt data types. These d


Examples : int, byte, long, short, char, float, double,

boolean.

(h) (i) Output:
5
10
(ii) 3 times

(i) a = a+ a++ + ++a + – – a + a – – ;


= 7 + 7 + 9 + 8 + 8 = 39

(j) (i) boolean (ii) String

Section B (60 Marks)

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 I Mnemonic Codes so that the logic of
the program is clearly depicted.
Flow-Charts and Algorithms are not required.

Question 4:
Define a class named BookFair with the following
description: [15]
Instance variables/Data members :
String Bname — stores the name of the book
double price — stores the price of the book Member
methods :
(i) BookFair() — Default constructor to initialize data
members
(ii) void Input() — To input and store the name and
the price of the book.
(iii) void calculate() — To calculate the price after
discount. Discount is calculated based on the
following criteria.

Price

Less than or equal to Rs. 1000


More than Rs. 1000 and less than or equal to Rs.

3000

More than % 3000

(iv) void display() — To display the name and price


of the book after discount. Write a main method to
create an object of the class and call the above
member methods.
Answer:
Question 5:
Using the switch statement, write a menu driven
program for the following: [15]
(i) To print the Floyd’s triangle [Given below]

2      3
4      5       6

7      8       9      10

11    12    13     14    15

(ii) To display the following pattern:

I  C

I     C      S

I     C      S     E

For an incorrect option, an appropriate error


message should be displayed.
Answer:
Question 6:
Special words are those words which starts and
ends with the same letter. [15]
Examples:
EXISTENCE
COMIC
WINDOW
Palindrome words are those words which read the
same from left to right and vice versa
Examples:
MALAYALAM
MADAM
LEVEL
ROTATOR
CIVIC
All palindromes are special words, but all special
words are not palindromes. Write a program to
accept a word check and print Whether the word is a
palindrome or only special word.
Answer:

Question 7:
Design n class to overload a function SumSeriesO
as follows: [15]
(i) void SumSeries(int n, double x) – with one integer
argument and one double argument to find and
display the sum of the series given below:

(ii) void SumSeries() – To find and display the sum


of the following series:
s = 1 + (1 x 2) + (1 x 2 x 3) + ….. + (1 x 2 x 3 x 4 x
20)

Answer:
Question 8:
Write a program to accept a number and check and
display whether it is a Niven number or not. [15]
(Niven number is that number which is divisible by
its sum of digits).
Example:
Consider the number 126.
Sum of its digits is 1+2+6 = 9 and 126 is divisible by
9.

Answer:

Question 9:
Write a program to initialize the seven Wonders of
the World along with their locations in two different
arrays. Search for a name of the country input by the
user. If found, display the name of the country along
with its Wonder, otherwise display “Sorry Not
Found!”. [15]
Seven wonders — CHICHEN ITZA, CHRIST THE
REDEEMER, TAJMAHAL, GREAT WALL OF
CHINA, MACHU PICCHU, PETRA, COLOSSEUM
Locations — MEXICO, BRAZIL, INDIA, CHINA,
PERU, JORDAN, ITALY
Example — Country Name: INDIA   Output: INDIA-
TAJMAHAL
Country Name: USA   Output: Sorry Not Found!
Answer:

ICSE Computer Applications Previous Year Question


Paper 2015 Solved for Class 10

ICSE Paper 2015


COMPUTER APPLICATIONS
(Two Hours)
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 are the default values of the primitive data
type int and float ? [2]
(b) Name any two OOP’s principles. [2]
(c) What are identifiers ? [2]
(d) Identify the literals listed below: [2]
(i) 0.5 (ii) ‘A’ (iii) false (iv) “a”
(e) Name the wrapper classes of char type and
boolean type. [2]

Answer:
(a) Default values of:
int 0
float 0.0

(b) Two OOP’s principles :


(i) Abstraction (ii) Inheritance.

(c) Identifiers: Identifiers are the symbolic names


given to variables, objects, classes etc.

(d) (i) 0.5—double type literal. (ii) ‘A’—char type


literal.
(iii) false—boolean type literal. (iv) “a”—string type
literal.

Question 2:
(a) Evaluate the value of a. if value of p = 5, q = 19
[2]
int n = (q – p) > (p – q) ? (q – p) : (p – q);
(b) Arrange the following primitive-data types in an
ascending order of their size:
(i) char (ii) byte (iii) double (iv) int [2]

(c) What is the value stored in variable res given


below :
double res = Math.pow (“345”.indexOf(‘5’), 3); [2]

(d) Name the two types of constructors [2]

(e) What are the values of a and b after the following


function is executed, if the values passed are 30 and
50: [2]
void paws(int a, int b)
{
a=a + b;
b=a – b;
a=a – b;
System.out.println (a+ “,” +b);
}

Answer:
(a) 14.

(b) byte, char, int, double.


(c) res =8

(d) Two types of constructor :


(i) default constructor
(ii) parameterized constructor.

(e) The value of a will be 50 and


The value of b will be 30.

Question 3:
(a) State the data type and value of y after the
following is executed:
char x=7;
y-Character.isLetter(x); [2]

(b) What is the function of catch block in exception


handling ? Where does it appear in a program ? [2]

(c) State the output when the following program


segment is executed:
String a =“Smartphone”, b=“Graphic Art”;
String h=a.substring(2, 5);
String k=b.substring(8).toUpperCase();
System.out.println(h);
System.out.println(k.equalsIgnoreCase(h)); [2]
(d) The access specifier that gives the most
accessibility is ………… and the least accessibility is
………… . [2]

(e) (i) Name the mathematical function which is used


to find sine of an angle given in radians.
(ii) Name a string function which removes the blank
spaces provided in the prefix and suffix of a
string. [2]

(f) (i) What will this code print ?


int arr[]=new int[5];
System.out.println(arr);
(i) 0
(ii) value stored in arr[0]
(iii) 0000
(iv) garbage value
(ii) Name the keyword which is used- to resolve the
conflict between method parameter and instance
variables/fields. [2]

(g) State the package that contains the class :


(i) BufferedReader
(ii) Scanner [2]
(h) Write the output of the following program
code: [2]
char ch ;
int x=97;
do
{
ch=(char) x;
System.out.print(ch + “ ” );
if(x%10 == 0)
break;
++x;
}while(x<=100);

(i) Write the Java expressions for a2+b22ab [2]


(ii) If int y = 10 then find int z = (++y * (y++ +5)); [2]
Answer:
(a) y = false.
data type of y is boolean.

(b) Catch block is used as exception handler in


exception handling. We can put the code to deal
with the execution that might arise, in this block.
Catch block must appear just below the tiy block.
(c) Output:
art
true.

(d) The access specifier that gives the most


accessibility is public and the least accessibility is
private.

(e) (i) Math.sin() (ii) trim ()

(f) (i) garbage value. (ii) ‘this’ keyword.

(g) (i) java.io package. (ii) java.util package.

(h) output: a b c d

(i) R = a*a + b*b/2*a*b;

(j) z = (11 * (11 + 5))


= 11 * 16
= 176

SECTION B (60 Marks)


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 so that the logic of
the program is clearly depicted.
Flow-Charts and Algorithms are not required.

Question 4:
Define a class named ParkingLot with the following
description :
Instance variables/data members:
int vno — To store the vehicle number
int hours — To store the number of hours the vehicle
is parked in the parking lot
double bill — Tb store the bill amount
Member methods:
void input( ) — To input and store the vno and
hours.
void calculate( ) — To compute the parking charge
at the rate of Rs.3 for the first hours or part thereof,
and Rs. 1.50 for each additional hour or part thereof.
void display ( ) — To display the detail
Write a main method to create an object of the class
and call the above methods. [15]
Answer:
Question 5:

Answer:
Question 6:
Write a program to input and store roll numbers,
names and marks in 3 subjects of n number
students in five single dimensional array and display
the remark based on average marks as given
below : (The maximum marks in the subject are
100) [15]

Answer:
Question 7:
Design a class to overload a function Joystring( ) as
follows :
(i) void Joystring (String s, char ch1 char ch2) with
one string argument and two character arguments
that replaces the character argument ch1 with the
character argument ch2 in the given string s and
prints the new string.
Example:
Input value of s = “TECHNALAGY”
ch1=‘A’,
ch2=‘O’
Output: TECHNOLOGY
(ii) void Joystring (String s) with one string argument
that prints the position of the first space and the last
space of the given string s.
Example:
Input value of = “Cloud computing means Internet
based computing”
Output: First index : 5
Last index : 36
(iii) void Joystring (String s1, String s2) with two
string arguments that combines the two string with a
space between them and prints the resultant string.
Example :
Input value of s1 =“COMMON WEALTH”
Input value of s2 =“GAMES”
Output: COMMON WEALTH GAMES
(use library functions) [15]
Answer:

Question 8:
Write a program to input twenty names in an array.
Arrange these names in descending order of
alphabets, using the bubble sort technique. [15]
Answer:

Question 9:
Using the switch statement, write a menu driven
program to:
(i) To find and display all the factors of a number
input by the user (including 1 and excluding number
itself).
Example:
Sample Input: n=15
Sample Output: 1, 3, 5.
(ii) To find and display the factorial of a number input
by the user (the factorial of a non-negative integer n,
denoted by n\ is the product of all integers less than
or equal to n.
Example:
Sample Input: n=5
Sample Output: 5! = 1×2×3×4×5 = 120.
For an incorrect choice, an appropriate error
message should be displayed. [15]
Answer:

ICSE Computer Applications Previous Year Question


Paper 2014 Solved for Class 10
ICSE Paper 2014
COMPUTER APPLICATIONS

(Two Hours)
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) Which of the following are valid comments ?
(i) /* comment */
(ii) /* comment
(iii) / / comment
(iv) */ comment */ [2]

(b) What is meant by a package ? Name any two


java Application Programming Interface
packages. [2]

(c) Name the primitive data type in Java that is :


(i) a 64-bit integer and is used when you need a
range of values wider than those provided by int.
(ii) a single 16-bit Unicode character whose default
value is ‘\u0000’. [2]

(d) State one difference between the floating point


literals float and double. [2]

(e) Find the errors in the given program segment


and re-write the statements correctly to assign
values to an integer array. [2]
int a = new int (5);
for (int i = 0; i < = 5; i++) a [i] = i;

Answer:
(a) (i) /* comment */
(iii) //comment
(b) A package in java is a mechanism for organizing
java classes into namespaces similar to the modules
of modula. Java packages allow classes in the same
package to access each other’s package-access
members.
Two Java application programming interface
packages are java.lang and java.io.

(c) (i) long
(ii) char.

(d)

float literals

The float literals has a limited range to store The doub

decimal data items.

(e) The corrected code is


int [ ] a = new int [5];
for(int i = 0; i < = 4; i++)
{
a[i]=i;
}

Question 2:
(a) Operators with higher precedence are evaluated
before operators with relatively lower precedence.
Arrange the operators given below in order of higher
precedence to lower precedence. [2]
(i) && (ii)% (iii) > = (iv) ++

(b) Identify the statements listed below as


assignment, increment, method invocation or object
creation statements. [2]
(i) System.out.println(“Java”);
(ii) costPrice = 457.50;
(iii) Car hybrid = new Car ();
(iv) petrolPrice++;

(c) Give two differences between the switch


statement and the If-else statement. [2]

(d) What is an infinite loop ? Write an infinite loop


statement. [2]

(e) What is constructor ? When is it invoked ? [2]


Answer:
(a) The operators are arranged in order of higher
precedence to lower precedence :
(i) ++ (ii) %  (iii) > = (iv) &&

(b) (i) System.out.println(“Java”);—method
invocation statement.
(ii) costPrice = 457.50;—assignment statement.
(iii) Car hybrid= new Car();—object creation
statement.
(iv) petrolPrice++;—increment statement.

(c)

Switch statement

In this statement, multicodes can be provided in which

control transfers to different parts of the code based on the

value of an expression.
Syntax :

if (condition)

statements;

Else

statements;

}
(d) An infinite loop can be created by skipping the
condition. This provides infinite statements to be
executed again and again.
An infinite loop statement :
int i;
for (i = 1; ; i++)
{
System.out.println(“This is an end loop”).
}

(e) A constructor is a special method which is called


automatically as soon as the object is created to
initialize the object. They has no return type not
even void. It has the same name as the class name.
A constructor is invoked as soon as the object is
created to initialize the object.

Question 3:
(a) List the variables from those given below that are
composite data types: [2]
(i) static int x;
(ii) arr[i]=10;
(iii) obj.display();
(iv) boolean b;
(v) private char chr;
(vi) String str;

(b) State the output of the following program


segment:
String str1 = “great”; String str2 = “minds”;
System.out.println (str1.substring
(0,2).concat(str2.substring (1)));
System.out.println ((“WH”+(str1.substring
(2).toUpperCase()))); [2]

(c) What are the final values stored in variable x and


y below ?
double a = – 6.35;
double b = 14.74;
double x = Math.abs(Math.ceil(a));
double y = Math.rint (Math max (a,b)); [2]

(d) Rewrite the following program segment using if-


else statements instead of the ternary operator:
String grade = (mark>=90) ? “A” : (mark>=80) ? “B” :
“C”; [2]

(e) Give the output of the following method:


public static void main (String [ ] args){
int a = 5;
a++;
System.out.println(a);
a- = (a – -) – (- – a);
System.out.println(a);} [2]

(f) What is the data type returned by the library


functions :
(i) compareTo()
(ii) equals() [2]

(g) State the value of characteristic and mantissa


when the following code is executed:
String s = “4.3756”;
int n = s.indexOf(‘.’);
int characteristic=Integer.parseInt (s.substring (0,n));
int mantissa=Integer.valueOf(s.substring(n+1)); [2]

(h) Study the method and answer the given


questions.
public void sampleMethod()
{ for (int i=0; i < 3; i++)
{ for (int j = 0; j<2; j++)
{int number = (int) (Math.random() * 10);
System.out.println(number); } } }
(i) How many times does the loop execute ?
(ii) What is the range of possible values stored in the
variable number ? [2]

(i) Consider the following class:


public class myClass {
public static int x=3, y=4;
public int q=2, b=3;}
(i) Name the variables for which each object of the
class will have its own distinct copy.
(ii) Name the variables that are common to all
objects of the class. [2]

(j) What will be the output when the following code


segments are executed ?
(i) String s = “1001”;
int x = Integer. valueOf(s);
double y = Double.valueOf(s);
System.out.println(“x=”+x);
System.out.println(“y=”+y);
System.out.println(“The king said\”Begin at the
beginning!\“to me.”); [2]

Answer:
(a) The composite data types are:
(i) string str;
(ii) arr[i] = 10;
(iii) obj.display();

(b) The output is as follows:


greinds
WHEAT

(c) The final values stored in:


x = 6 and y = 15

(d) The code using if-else statement is:


if (mark >= 90)
{
String grade = “A”;
}
else
{
if ( mark >= 80)
{
String grade = “B”;
}
else
{
String grade = “C”;
}
}
(e) The output of the method:
6
4

(f) (i) compare To( ) returns an int value.


(ii) equal () returns boolean value.

(g) Value of characteristic = 4 and


Value of mantissa = 3756.

(h) (i) 6 times.
(ii) range between 0 and 10.

(i) (i) ‘a’ and ‘b’.


(ii) ‘x’ and ‘y’.

(j) The output is:


(i) x = 1001
y = 1001.000000
(ii) The king said “Begin at the beginning !” to me.

SECTION B (60 Marks)

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 so that the logic of
the program is clearly depicted.
Flow-Charts and Algorithms are not required.

Question 4:
Define a class named movieMagic with the
following description:
Instance variables/data members:
int year — to store the year of release of a movie.
String title — to-store the title of the movie
float rating — to store the popularity rating of the
movie
(minimum rating=0.0 and maximum rating=5.0)

Member methods:
(i) movieMagic() Default constructor to initialize
numeric data members to 0 and String data member
to “ ”.
(ii) void accept() To input and store year, title and
rating.
(iii) void display() To display the title of a movie and
a message based on the rating as per the table
below.
Rating Me

0.0 to 2.0

2.1 to 3.4

3.5 to 4.5

4.6 to 5.0

Write a main method to create an object of the class


and call the above member methods. [15]
Answer:
Variable Description:

S.No. Variable Name Data type

1. year int

2. title string

3. rating float
4. IR —

5. br —

6. obj —

Question 5:
A special two-digit number is such that when the
sum of its digits is added to the product of its digits,
the result is equal to the original two-digit number.
Example: Consider the number 59.
Sum of digits = 5 + 9=14
Product of its digits = 5 x 9 = 45
Sum of the sum of digits and product of digits = 14 +
45 = 59
Write a program to accept a two-digit number. Add
the sum of its digits to the product of its digits. If the
value is equal to the number input, output the
message “Special 2-digit number” otherwise, output
the message “Not a special 2-digit number”. [15]

Answer:
The variable description is as follows:

S.No. Variable Name Data type

1. num int
2. sum int

3. pro int

4. final sum int

5. IR —

6. hr —

7. digit int
8. n int

9. obj —

Question 6:
Write a program to assign a full path and file name
as given below. Using library functions, extract and
output the file path, file name and file extension
separately as shown.
Input C: / Users / admin / Pictures / flower.jpg
Output path: C: / Users/admin/Pictures/
File name: flower
Extension: jpg [15]

Answer:
The variable description is as follows:

S.No. Variable Name Data type

1. pathname string

2. filename string
3. extensionname string

4. path string

5. IR —

6. br —

7. r int
8. s int

Question 7:
Design a class to overload a function area( ) as
follows:
(i) double area (double a, double b, double c) with
three double arguments, returns the area of a
scalene triangle using the formula:
area = s(s−a)(s−b)(s−c)−−−−−−−−−−−
−−−−−−√2ab
where s=a+b+c2
(ii) double area (int a, int b, int height) with three
integer arguments, returns the area of a trapezium
using the formula:
area = 12 height (a + b)
(iii) double area (double diagonal 1, double diagonal
2) with two double arguments, returns the area of a
rhombus using the formula :
area = 12 (diagonal 1 x diagonal 2)  [15]
Answer:
The variable description is as follows:

S.No. Variable Name Data type

1. a double

2. b double
3. c double

4. s double t

5. r double t

6. area double

7. a int

8. b int

9. height int
10. diagonal 1 double

11. diagonal 2 double

Question 8:
Using the switch statement, write a menu driven
program to calculate the maturity amount of a Bank
Deposit.
The user is given the following options :
(i) Term Deposit
(ii) Recurring Deposit
For option (i) accept principal (P), rate of interest(r)
and time period m years(n). Calculate and output the
maturity amount (A) receivable using the formula

For option (ii) accept Monthly Installment (P), rate of


interest (r) and time period in months (n). Calculate
and output the maturity amount (A) receivable using
the formula

For an incorrect option, an appropriate error


message should be displayed.  [15]

Answer:

Question 9:
Write a program to accept the year of graduation
from school as an integer value from, the user.
Using the Binary Search technique on the sorted
array of integers given below.
Output the message “Record exists” If the value
input is located in the array. If not, output the
message “Record does not exist”.
{1982, 1987, 1993, 1996. 1999, 2003, 2006, 2007,
2009, 20101.  [15]
Answer:

You might also like