|| Jai Sri Gurudev ||
BGS WORLD SCHOOL
Mahalakshmipuram, Bangalore-86
2024-2025
SESSION-III
SUBJECT: COMPUTER APPLICATIONS
GRADE: X TOPIC: User Defined Methods TOTAL MARKS: 20
Question1
Choose the correct answer. [6]
1) Alternative way to send multiple values from a function is:
a) Arrays b) Lists c) Tuples d) None
2) The default return type of a User defined function is
a) float b) int c) void d) Null
3) A user defined function in Java can return ___ number of values.
a) 1 b) 2 c) 3 d) Any number
4) A declaration can occur ____ in a body of a user defined method.
a) In the beginning b) In the middle
c) At the end d) Anywhere
5) The prototype of a function “show()” that returns a float and takes two
int value is _____.
a) public show() b) public show(int a, int b)
c) public void show(int, float) d) public float show(int, int)
Question 2
1) Write the output for the below codes.
a) void sum(int n) [2]
{
if(n%2==0)
print(Math.pow(n,2))
else
print(Math.pow(n,3))
void main()
{ sum(7);
}
b) void result(int num) [2]
{ sum=0;
While(num>0)
{
d=num%10;
|| Jai Sri Gurudev ||
if( d%3 ==0)
sum= sum+d;
else
sum= sum-d;
num=num/10;
}
System.out.println(sum+””); }
Void main()
{
result(6972);
}
Question 3
1) Define impure functions with an example. [2]
2) What is the importance of function overloading? [2]
3) Write any 2 differences between call by value and call by reference. [2]
Question 3 (Any two) [4]
1) Write a program to create a class Employee and basic as its data member, to find
The gross pay of an employee of the following allowance and deduction.
Allowance= 25% of basic pay house rent allowance = 15% of basic pay provident
fund=8.33% of basic pay.
Net pay= basic pay+ allowance+ House rent allowance.
Gross pay = net pay – Provident fund
2) Design a class to overload a function volume() as follows:
i. double volume(double R)- with radius ( R ) as the arguments, returns the volume
of a sphere using the formula, V= 4/3 * R2 * R3.
ii. double volume(double H, double R)- with height ( H ) and radius ( R ) as the
arguments, returns the volume of a cylinder using the formula, V= 22/7 * R2 * H.
iii. double volume(double H, double B, double L )- with length ( L ) , height ( H )
and radius ( R ) as the arguments, returns the volume of a cuboid using the
formula, V= L*B*H
********