9 Computer Applications (Theory)
9 Computer Applications (Theory)
CLASS IX
Question No 1
(a) What is a literal? [2]
Question No 2
(a) Rewrite the following loop using the ‘for’ loop: [2]
while(true)
System.out.print(“*”);
(b) Mention the number of bytes occupied by short and float data types. [2]
Question No 3
2
m = 3 (a2 – b2)h
(f) Write the equivalent ‘do-while’ loop for the following program segment: [2]
int n = 40;
for( int y = 10; y>=2; y– –)
n++;
(g) Write the Java statement to create an object emp of class Organization. [2]
(3)
(h) How many times will the following loop execute and what will be the final output? [2]
(i) Give the prototype of a function search() which receives an integer in variable num
and a double value in variable cal and returns 1 or 0. [2]
int y = 5;
for (;y<=19; y+=2)
System.out.println(y);
Question No 4
(a) 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 )
a+b+c
where s =
2
(b) double area(int a, int b, int height) with three integer arguments, returns the area of a
trapezium using the formula:
1
area = height ( a + b )
2
(4)
(c) double area(double diagonal1, double diagonal2) with two double arguments, returns
the area of a rhombus using the formula:
1
area = height (diagonal1 × diagonal2)
2
Write a main() method to call the overloaded methods.
Question No 5
Write a menu-driven program to perform the following as per the user's choice: [15]
(a) Generate and display the first 10 terms of the Fibonacci series 0,1,1,2,3,5….The
first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of
the previous two.
Question No 6
String name,
int age,
double average
Member functions:
(i) void accept() : to accept the details of a student including name, age and
marks in 3 subjects
(ii) void compute() : to calculate the average and the maximum out of the 3 marks
(iii) void display() : to display the name, age, marks in 3 subjects, maximum and
average
Write a main method to create an object of the class Student and call the above member
methods.
(5)
Question No 7
Write a menu-driven program to perform the following as per the user’s choice: [15]
a2 a3 a 4
s = a− + − + ..... upto n terms
2 3 4
s = 1 + 2 + 4 + 7 + 11 + 16 + …. + n
Question No 8 [15]
Write a program to input a number and check and print whether it is a Pronic number or
not. Pronic number is a number which is the product of two consecutive integers.
Examples: 12 = 3 × 4
20 = 4 × 5
42 = 6 × 7
Question No 9 [15]
Write a program to print the following pattern based on the number of terms input by the
user:
21
321
4321
54321
654321
7654321