STD.
X / COMPUTER APPLICATIONS / USERDEFINED METHODS / MARKS: 40 / TIME :1 HR
Q.1 CHOOSE THE CORRECT OPTION [20 M]
1. A _______ is a set of statements written by the user to perform some special tasks.
i. statements ii. class iii. function iv. objects
2. A ________ is the first line of the function definition and tells the program about the type of
value returned by the method and the number and type of arguments passed to it.
i. method signature ii. method parameters iii. Method body iv. Method prototype
3. A ________ refers to the number and type of arguments passed in the method.
i. method signature ii. method parameters iii. Method body iv. Method prototype
4. _______ is used as the return type for methods that do not return a value.
i. void ii. public iii. static iv. double
5. _______ parameters appear in the function call statement.
i. formal ii. actual iii. arguments iv. class
6. _______ parameters appear in the function definition.
i. formal ii. actual iii. arguments iv. class
7. The two ways of invoking / calling functions are _____ & _____ .
i. call by value ii. call by reference iii. both i & ii iv. pass by reference
8. The _______ statement transfers the control back to the calling function.
i. break ii. return iii. continue iv. jump
9. A _____ method that does not changes the state of an object.
i. pure ii. impure iii. static iv. non-static
10. A _____ method that changes the state of an object.
i. pure ii. impure iii. static iv. non-static
11. _______ is a concept in which multiple methods of the same name are differentiated by their
parameters by datatype or number, and all methods work in different ways.
i. Function overriding ii. Function overloading iii. Function loading iv. Both i & ii
12. The only OOP principal that supports Method Overloading.
i. Abstraction ii. Encapsulation iii. Inheritance iv. Polymorphism
13. __________ are passed to methods by use of call by reference.
i. Variables ii. Objects iii. Methods iv. Operators
14. Which of these data type can be used for a method having a return statement in it?
i. void ii. float iii. int iv. both int & float
15. The number of values that a function can return is :
i. 1 ii. 2 iii. 3 iv. 4
16. A _________method needs to be called with the help of an object.
i. void ii. class iii. non-static iv. static
17. System.exit(0) terminates the program from any point.
i. true ii. false
18. Assertion (A) : Method signature is a part of function prototype which comprises of the
method name and the data types of the parameters.
Reason (R) : First line of function definition that tells about the type of value returned by
the function and the number and type of arguments is called function
prototype.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is correct explanation
Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not correct explanation of
Assertion (A)
(c) Assertion (A) is true and Reason (R) is false.
(d) Assertion (A) is false and Reason (R) is true.
19. Functions perform the task designed by the user. The first line of the function declaration
is known as function prototype. Parameters that appear in function definition is known as
formal parameters and the parameters that appears in function calling statements is
known as Actual parameters. The two ways of calling function are Call by value and Call by
reference. The function that does not changes the state of an object is known as pure
function and function that changes the state of an object is known as impure function.
Functions with same name but with different parameters is known as function
overloading. Function overloading implements OOP principle known as Polymorphism.
___________ is an Access-Modifier in the function definition statement.
i. void ii. class iii. public iv. static
20. Assertion (A) : Functions divides the programs into smaller modules.
Reason (R) : By dividing, the program code becomes easier to understand.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is correct explanation
Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not correct explanation of
Assertion (A)
(c) Assertion (A) is true and Reason (R) is false.
(d) Assertion (A) is false and Reason (R) is true.
Q.2 Answer the following [20 M]
1. Write a function prototype statement that accepts a sentence and a word that returns true
or false value.
2. Write a function prototype statement that accepts two integer parameters and returns
decimal value.
3. Write a function prototype statement that accepts two-character parameters and returns
no value.
4. Identify the formal and actual parameters given in the program segment.
public static double Sum (double x, double y) {
double z = x + y; }
public static void main(double x, double y) {
obj.Sum(x,y); }
5. Which of the following are pre-defined and user-defined functions :
i. Accept() ii. ceil() iii. next() iv. Calculate()
6. Sam has created a function called check(). He wants the function to return the double
value but error occurs as “missing return statement”. Fix the code with correct
statements.
public static double check(double a , double b) {
System.out.println(a * b); }
7. Write the answers for the given definitions:
i. The functions that does not changes the state of an object.
ii. The values are copied from actual to formal parameters through the object.
8. Write the two ways for calling/invoking functions in the java program.
9. Define function overloading with example. [4 M]
**********************************************ALL THE BEST**********************************************