Solved 2014 Question Paper ICSE Class 10 Computer Applications
Solved 2014 Question Paper ICSE Class 10 Computer Applications
Section A
Question 1
1. /*comment*/
2. /*comment
3. //comment
4. */comment*/
Answer
Option 1 — /*comment*/
Option 3 — //comment
(b) What is meant by a package ? Name any two java Application Programming
Interface packages.
Answer
A package is a named collection of Java classes that are grouped on the basis of their
functionality. Two java Application Programming Interface packages are:
1. java.util
2. java.io
1. a 64-bit integer and is used when you need a range of values wider than those
provided by int.
2. a single 16-bit Unicode character whose default value is '\u0000'.
Answer
1. long
2. char
(d) State one difference between the floating point literals float and double.
Answer
float literals have a size of 32 bits so they can store a double literals have a size of 64 bits so they can
fractional number with around 6-7 total digits of store a fractional number with 15-16 total digits o
precision. precision.
(e) Find the errors in the given program segment and re-write the statements correctly
to assign values to an integer array.
Corrected Code:
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:
1. &&
2. %
3. >=
4. ++
Answer
++
%
>=
&&
(b) Identify the statements listed below as assignment, increment, method invocation or
object creation statements.
1. System.out.println("Java");
2. costPrice = 457.50;
3. Car hybrid = new Car();
4. petrolPrice++;
Answer
1. Method Invocation
2. Assignment
3. Object Creation
4. Increment
(c) Give two differences between the switch statement and the if-else statement
Answer
switch if-else
switch can only test if the expression is equal if-else can test for any boolean expression like less than,
to any of its case constants greater than, equal to, not equal to, etc.
Answer
A loop which continues iterating indefinitely and never stops is termed as infinite loop.
Below is an example of infinite loop:
for (;;)
System.out.println("Infinite Loop");
(e) What is constructor? When is it invoked?
Answer
A constructor is a member method that is written with the same name as the class name and is
used to initialize the data members or instance variables. A constructor does not have a return
type. It is invoked at the time of creating any object of the class.
Question 3
(a) List the variables from those given below that are composite data types:
1. static int x;
2. arr[i]=10;
3. obj.display();
4. boolean b;
5. private char chr;
6. String str;
Answer
arr[i]=10;
obj.display();
String str;
grinds
WHEAT
Explanation:
(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));
Answer
Explanation:
Answer
String grade;
if (marks >= 90)
grade = "A";
else if (marks >= 80)
grade = "B";
else
grade = "C";
(e) Give the output of the following method:
Output
6
4
Explanation
⇒ a = a - ((a--) - (--a))
2. a -= (a--) - (--a)
⇒ a = 6 - (6 - 4)
⇒a=6-2
⇒a=4
1. compareTo()
2. equals()
Answer
1. int
2. boolean
(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));
Answer
s.substring(n+1) gives 3756 i.e. the string starting at index 2 till the end of s.
Integer.valueOf() converts string "3756" into integer 3756 and this value is assigned to the
variable mantissa.
Answer
1. Name the variables for which each object of the class will have its own distinct
copy.
2. Name the variables that are common to all objects of the class.
Answer
1. a, b
2. x, y
(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);
(ii)
x=1001
y=1001.0
(ii) The output of the code is:
Question 4
Member
Purpose
Methods
Default constructor to initialize numeric data members to 0 and String data member
movieMagic()
"".
To display the title of the movie and a message based on the rating as per the table
void display()
given below
Ratings Table
Write a main method to create an object of the class and call the above member methods.
Answer
import java.util.Scanner;
public movieMagic() {
year = 0;
title = "";
rating = 0.0f;
}
System.out.println(title);
System.out.println(message);
}
Output
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.
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, then display the message "Special two—digit
number" otherwise, display the message "Not a special two-digit number".
Answer
import java.util.Scanner;
while (num != 0) {
int digit = num % 10;
num /= 10;
digitSum += digit;
digitProduct *= digit;
count++;
}
if (count != 2)
System.out.println("Invalid input, please enter a
2-digit number");
else if ((digitSum + digitProduct) == orgNum)
System.out.println("Special 2-digit number");
else
System.out.println("Not a special 2-digit
number");
}
}
Output
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
Answer
import java.util.Scanner;
System.out.println("Extension:\t" +
filepath.substring(dotIdx + 1));
}
}
Output
Question 7
1. 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))
where s = (a+b+c) / 2
2. double area (int a, int b, int height) with three integer arguments, returns the area of a
trapezium using the formula:
area = (1/2)height(a + b)
3. double area (double diagonal1, double diagonal2) with two double arguments, returns
the area of a rhombus using the formula:
area = 1/2(diagonal1 x diagonal2)
Answer
import java.util.Scanner;
Output
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:
1. Term Deposit
2. Recurring Deposit
For option 1, accept principal (P), rate of interest(r) and time period in years(n). Calculate and
output the maturity amount(A) receivable using the formula:
A = P[1 + r / 100]n
For option 2, 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:
A = P x n + P x (n(n+1) / 2) x r / 100 x 1 / 12
Answer
import java.util.Scanner;
switch (ch) {
case 1:
System.out.print("Enter Principal: ");
p = in.nextDouble();
System.out.print("Enter Interest Rate: ");
r = in.nextDouble();
System.out.print("Enter time in years: ");
n = in.nextInt();
a = p * Math.pow(1 + r / 100, n);
System.out.println("Maturity amount = " + a);
break;
case 2:
System.out.print("Enter Monthly Installment: ");
p = in.nextDouble();
System.out.print("Enter Interest Rate: ");
r = in.nextDouble();
System.out.print("Enter time in months: ");
n = in.nextInt();
a = p * n + p * ((n * (n + 1)) / 2) * (r / 100) *
(1 / 12.0);
System.out.println("Maturity amount = " + a);
break;
default:
System.out.println("Invalid choice");
}
}
}
Output
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".
Sample Input:
n[0] n[1] n[2] n[3] n[4] n[5] n[6] n[7] n[8] n[9
1982 1987 1993 1996 1999 2003 2006 2007 2009 2010
Answer
import java.util.Scanner;
if (idx == -1)
System.out.println("Record does not exist");
else
System.out.println("Record exists");
}
}
Output