Application
Application
COMPUTER APPLICATIONS
(Theory)
(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.
Question 1.
Question 2.
(a) Assign the constant value of pi (i.e. 3.142) to a variable mentioning its appropriate
data type. [2]
(b) Name the Java keyword that:
(i) is used to finish the execution of a method.
(ii) is used to implement the concept of inheritance. [2]
(c) If int A[ ] = {9,8,0,4,5,6,6,8,1,5}; What are the values of 'm' and 'n'?.
m = Math.max(Math.pow(A[1],A[2]) , Math.sqrt(A[3]));
n = Math.pow(Math.min(A[1],A[7]), A[3]); [2]
(d) What is the difference between a String object and StringBuffer object? [2]
(e) Write a Java statement to check whether two string object 's1' and 's2' are equal or
not, using compareTo() function. [2]
Question 3.
(a) Rewrite the following code fragment without break and continue.
while(ch != '*')
{
if(ch == '?')
break;
if(ch != '\n')
continue;
line++;
} [3]
(b) What will be the result of the following code:
String s1 = "Feeling Sleepy";
String s2 = "Watching Television";
(i) System.out.println(s1.compareTo(s2));
(ii) System.out.println(s1.concat(" Still ").concat(s2)); [2]
(c) State the difference between Selection Sort and Bubble Sort. [2]
(d) Find the errors in the following code snippet and correct them:
boolean true = a;
If(false)
System.Out.Println("Nothing in here")
else
System.out.println(Correct this mistake); [3]
Question 4.
(a) State the purpose and return datatype of the following wrapper class functions:
(i) toString(long n)
(ii) parseLong(String s) [2]
(b) Identify the following as valid or invalid identifier names. State reasons.
(i) _123 (ii) break
(iii) T$ (iv) var.1 [2]
(c) Analyze the following program segment and answer the following questions:
class JavaForSchool
{
public void methodInfo()
{
char a = 'A', b = 'a';
int c = a++ + b;
}
}
(i) What value is stored in 'c' after the method gets executed?
(ii) What is the value stored in 'a' after the execution of the method?
(iii) Define the main() method which calls the above method.
(iv) Modify methodInfo() so that the resultant 'c' is displayed on the screen. [4]
(d) What is the scope of the keyword 'protected' in accessing a method. [2]
2
TSP008 © www.javaforschool.com
JAVA FOR SCHOOL SAMPLE PAPER 8
Making Java Fun To Learn ICSE (Class X)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Question 5. [15]
Question 6. [15]
Member functions:
WordOp() : default constructor
void input() : to accept the word in UPPERCASE
void calcMaxMin() : to find the highest and the lowest character present in the word.
void display() : to display the word along with the highest and the lowest character
Example: If word is "TWEAK"
Highest Character = W
Lowest Character = A
Question 7. [15]
3
TSP008 © www.javaforschool.com Turn over
JAVA FOR SCHOOL SAMPLE PAPER 8
Making Java Fun To Learn ICSE (Class X)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Question 8. [15]
The production (P) of crude oil of a country in millions of barrels may be estimated by the
following set of equations, where t represents the time duration in years:
P = 5 + 3t for 0 ≤ t ≤ 3
P = 14 + (t - 5/2)2 for t > 3
Write a program in Java to input a year from the user and find and print the production for
every year from the year 2000 to the inputted year.
Print the output in the following format:
Year Production
---------- ----------
---------- ----------
---------- ----------
Question 9. [15]
A cloth showroom has announced the following seasonal discounts on purchase of items:
Discount
Purchase Amount (`)
Mill Cloth Handloom Items
0 - 1000 ------- 5%
Above 3000 10 % 15 %
Write a Java program to input the purchase amount and Item Code viz : M or m for Mill Cloth
and H or h for Handloom Items.
Calculate the discount amount. Find the net balance to be paid excluding the discount.
Print the Purchase Amount, Item Type, Discount and the net amount to be paid.
Write a program to input an integer array A[] of n size. Sort the array in ascending order.
Then input another number from the user and replace all the numbers less than that inputted
number by their reverse.
Example : If A[] = {38, 25, 16, 91, 5, 12} then,
array after sorting is {5, 12, 16, 25, 38, 91}
If the number entered = 20 then,
after replacing all the numbers less than 20 with their reverse,
final Output is {5, 21, 61, 25, 38, 91}
4
TSP008 © www.javaforschool.com