For More Sample Papers Visit:: (Theory)
For More Sample Papers Visit:: (Theory)
com
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.
(b) What is meant by a package? Name any two Java Application Programming
Interface packages. [2]
(d) State one difference between floating point literals float and double. [2]
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.
(i) && (ii) % (iii) >= (iv) ++ [2]
(b) Identify the statements listed below as assignment, increment, method invocation or
object creation statements.
(i) System.out.println("Java");
(ii) costPrice = 457.50;
(iii) Car hybrid = new Car();
(iv) petrolPrice++; [2]
(c) Give two differences between switch statement and if-else statement. [2]
(d) What is an infinite loop? Write an infinite loop statement. [2]
(e) What is a constructor? When is it invoked? [2]
Question 3.
(a) List the variables from those given below that are composite data types.
(i) static int x; (iv) boolean b;
(ii) arr[i]=10; (v) private char chr;
(iii) obj.display(); (vi) String str; [2]
2
T14 861 © www.javaforschool.com
(c) What are the final values stored in variables 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 the if-else statements instead of the
ternary operator.
String grade = (mark>=90) ? "A" : (mark>=80) ? "B" : "C"; [2]
(e) Give 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?
3
T14 861 © www.javaforschool.com Turn over
(ii) What is the range of possible values stored in the variable number? [2]
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
such that the logic of the program is clearly depicted.
Flow-Charts and Algorithms are not required.
Question 4.
4
T14 861 © www.javaforschool.com
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.
Write a main method to create an object of the class and call the above member methods. [15]
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]
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]
5
T14 861 © www.javaforschool.com Turn over
Question 7.
area = ( − )( − )( − )
where s =
(ii) double area(int a, int b, int height) with three integer arguments, returns the area of a
trapezium using the formula:
(iii) double area(double diagonal1, double diagonal2) with two double arguments, returns
the area of a rhombus using the formula:
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 in years(n). Calculate
and output the maturity amount (A) receivable using the formula A= P 1+
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
( )
A=P×n+P× × ×
6
T14 861 © www.javaforschool.com
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, 2010} [15]
7
T14 861 © www.javaforschool.com Turn over
© www.javaforschool.com