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 | double literals |
The float literals has a limited range to store decimal data items. | The double literals has a wider range as compared to float to store 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 | if-else 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. | In this statement, there are only two codes based on either a true or a false condition. |
Syntax : if (condition) { statements; } Else { statements; } | Syntax : switch (expression) { case constant 1; statement 1; break; case constant 2; statement 2; break; : : default : statement sequence; } case |
(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 | Message to be displayed |
0.0 to 2.0 | Flop |
2.1 to 3.4 | Semi-hit |
3.5 to 4.5 | Hit |
4.6 to 5.0 | Super Hit |
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 | Purpose |
1. | year | int | to store the year of release of the movie. |
2. | title | string | to store the title of movie |
3. | rating | float | to store popularity rating of the movie |
4. | IR | — | for input stream reader |
5. | br | — | for buffered reader |
6. | obj | — | for object of the class |
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 | Purpose |
1. | num | int | to enter the 2-digit number |
2. | sum | int | to store sum of the digits |
3. | pro | int | to store product of digits |
4. | final sum | int | to store sum of “sum and product of the digits”. |
5. | IR | — | for input stream Reader |
6. | hr | — | for buffered Reader |
7. | digit | int | to store remainder, i.e. each digit |
8. | n | int | to store the 2-digit number |
9. | obj | — | for object of the class |
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 | Purpose |
1. | pathname | string | to store full path name of file |
2. | filename | string | to store file name |
3. | extensionname | string | to store extension of file |
4. | path | string | to store only pathname with file and extension name |
5. | IR | — | for input stream reader |
6. | br | — | for buffered reader |
7. | r | int | to store position no. of string “/”. |
8. | s | int | to store position number of string |
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 = \(\sqrt { s(s-a)(s-b)(s-c) }{ 2ab } \)
where \(s=\frac { a+b+c }{ 2 } \)
(ii) double area (int a, int b, int height) with three integer arguments, returns the area of a trapezium using the formula:
area = \(\frac { 1 }{ 2 } \) 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 = \(\frac { 1 }{ 2 } \) (diagonal 1 x diagonal 2) [15]
Answer:
The variable description is as follows:
S.No. | Variable Name | Data type | Purpose |
1. | a | double | to enter side of the triangle |
2. | b | double | to enter side of the triangle |
3. | c | double | to enter side of the triangle |
4. | s | double | to store the value of s in area formula used. |
5. | r | double | to store the value of r in area formula used. |
6. | area | double | to store area of various shapes |
7. | a | int | to enter side of trapezium |
8. | b | int | to enter side of trapezium |
9. | height | int | to enter height of trapezium |
10. | diagonal 1 | double | to enter diagonal of rhombus |
11. | diagonal 2 | double | to enter diagonal of rhombus |
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: