You are on page 1of 5

PRELIMINARY EXAMINATION – 2020

COMPUTER APPLICATION
Grade: 10 Duration: 2 Hours
Date: 09/01/2020 Max. Marks: 100
[The time stated above is the time allowed for writing the examination. In addition,
the first 15 minutes will be the time given for reading the question paper.]
All working, including rough work should be done on the same sheet as rest of the
answer. The intended marks for questions or parts of questions are given in brackets.
Section A
Answer all questions
Give examples and briefly indicate the working or reasoning.

Question 1
a. Differentiate between static and non-static data members in a class.
[2]

b. What is meant by Constructor overloading? Give a simple example. [2]

c. What will the following functions return when executed? [1]


(j) Math.max(-17, -19) (ii) Math.ceil(7.8)

d. What are the two ways of invoking functions? [2]

e. (i) Name the package that contains Scanner class. [1]


(ii) Which unit of the class gets called, when the object of the class is created?

f. Differentiate between Formal parameters and Actual Parameters [2]

Question 2

a. State the Java concept that is implemented through: [1]


i) a super class and a subclass.
ii) the act of representing essential features without including background details.

b. 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;

c. State the value of characteristic and mantissa in the following code snippet. [2]
String s = "4.3756";
int n = s.indexOf('.');
int characteristic = Integer.parseInt(s.substring(0,n));
int mantissa = Integer.valueOf(s.substring(n+1));

Page 1 of 5
d. How are private members of a class different from public members? [2]

e. 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));

f. Give the output of the following code snippet [1]


int a=5;
System.out.println(a++);
a -= (a--) - (--a);
System.out.println(a);

Question 3

a. State at least 2 differences between a method and a constructor. [2]

b. What will be the value in K, if a =3 and b=6? [1]


K=a+3==b+3;
c. State at least 2 advantages of using methods. [2]

d. Give the output. [1]


String s=”MISTAKEN IDENTITY”
int i=1;
System.out.println(s.charAt(i+1)==s.charAt(i)+1);

e. State the difference between an entry-controlled loop and an exit-controlled loop.


[2]
f. Name the type of error (syntax, runtime or logical error) in each case given below
also state the reason. [2]
(i) Math.sqrt (36-45) (ii) int a;b;c;

Question 4

(a) State two differences between an Arithmetic Expression and a Logical Expression. [2]

(b) What is Promotion? Explain with an appropriate example.


[2]

(c) Explain the difference between = and == with an example. [2]


(d) Give the output of the following code snippet (with complete working). [2]
(i) int i=0, a=0, b=0,c=0;
while(i<=5) {
switch(i++) {
case 1 : a++;
case 2 :
case 3 : b++;
Page 2 of 5
case 4 :
default : c++;
}
}
System.out.println(a+ “ “ + b + “ “ + c);

(e) What is an Exception? Give 2 examples. [2]

Section B (60 Marks)


Answer any 4. Comment lines and variable description needs to written.

Question 5 [15]
Accept a positive integer from the user and check if it occurs in the Fibonacci series. A
number is said to be a Fibonacci number, if it occurs in the Fibonacci Series.
For example, if the user enters 6, then it should display the message, “6 does not occur
in the Fibonacci Series. If the user enters 21, the program should display the message,
“21 occurs in the Fibonacci series”.
By definition, the first two numbers in the Fibonacci sequence are 0 and 1 and each
subsequent number is the sum of the previous two.
Fibonacci Series: 0,1,1,2,3,5,8,13,21…etc.

Question 6 [15]
Write a program to merge two single dimension arrays as shown in the following example
and display the merged array.
For example if,
Array X has the values: 5, -3, -2, 1, 0, 12, 14, 16, 25, 13
Array Y has the values:6, 5, 10, 15, 18, 20, 22, 30
Arrays Z should have the merged values as shown below:
5, 6, -3, 5, -2, 10, 1, 15, 0, 18, 12, 20, 14, 22, 16, 30, 25,13

Question 7 [15]

Define a class EBILL having the following specification

Data Members:
String name : stores the consumer’s name.
char cust_cat : stores the customer category Residential or Industrial (R or I)
int prv, pre : stores the previous and present meter readings respectively.
int unit : stores the unit consumed
double amt : to store the amount.

Member function:
void input () : to accept the name, category, previous and the present reading

void calc(): Calculates the units consumed using the previous and the present reading
and also the amount to be paid based on the tariff rates shown below.

void display():displays name of consumer, unit consumed and amount to be paid.

Page 3 of 5
Residential
Consumption (kWh)/ month Slab tariff (fils/kWh)
0-2000 23
2001-4000 28
4001-6000 32
6001 & Above 38

Industrial
Consumption (kWh)/ month Slab tariff (fils/kWh)
0-10000 25
10001 & Above 38

Accept the customer details, calculate the bill amount and display the bill by creating
objects in main().

Question 8 [15]
A class called numbers has the following overloaded functions:

public static boolean check_num(String n)


Returns true if the given String has 0’s and 1’s only and false otherwise

public static boolean check_num(int n)


Returns true if the given number consists of digits 0 to 7 only and false if it contains 8 or
9.

Define the main() method and call the methods appropriately.

Question 9 [15]

Write a program that displays a menu and executes one of the following based on user’s
choice.
MENU
a. PRINT SUM OF THE SERIES
b. PRINT PATTERN
c. Exit
a. Input the values of x and n from the user and calculate the sum of the following series
and display the sum
Sum = 1 / x2 + 4 / x5 + 7 / x8 + 10 / x11 + ……. to n terms
b. Print the following pattern
1 5 9 13 17
5 9 13 17
9 13 17
13 17
17

Page 4 of 5
The program should repeat as long as the user wishes to continue and it should terminate
when the user chooses option c.

Question 10 [15]

Write a program to fill a matrix with the following data and display the matrix as shown
below.

1 2 3 4 5 6 7 8 9 10
2 4 6 8 10 12 14 16 18 20
3 6 9 12 15 18 21 24 27 30
4 8 12 16 20 24 28 32 36 40
5 10 15 20 25 30 35 40 45 50
6 12 18 24 30 36 42 48 54 60
7 14 21 28 35 42 49 56 63 70
8 16 24 32 40 48 56 64 72 80
9 18 27 36 45 54 63 72 81 90
10 20 30 40 50 60 70 80 90 100

**************************************************************************

Page 5 of 5

You might also like