Anda di halaman 1dari 3

FUNCTIONS NOTES FOR GRADE 9

FUNCTION
Ques 1 what is function ?Write advantage of using function
Ans :- Functions are methods that contain codes to perform a specific task and returns values for
further computation .
OR
Functions are the modules from which java programs are built. Modular code is easy to debug
and maintain.
Function provides as
1. Reusability of the code
2. they hide low level details
3. They make program easy to debug and maintain.
Ques 2- What are actual and formal parameters of a functions?
Ans :- Arguments are known as actual parameters. Parameters are the variables defined by a
method that receives values known as formal parameters.
Actual parameter appears in function call where as formal parameters appears in function
signature.
Ques 3:- What is the role of a return statement in a function?
Ans :-public int add(int n, int m)
{
return n+m;
}
The return statement will send the sum of n and m to the calling body.
Ques 4:- What is the role of void keyword in declaring functions.
Ans :- a void keyword signifies that the method does not return any value to its caller.
Ques 5:-What is function overloading? 2006
Ans :- the process of having two or more methods or functions with in a class, with same name
but different parameters declaration is known as function overloading.
Ques 6:- What is function signature?
Ans :- Parameter of the function along with function name. It is also known as function
signature.
Ques 7- What is parameters?

1
FUNCTIONS NOTES FOR GRADE 9

Ans :- List of variable that recives the value of the arguments passed to the function when
is called. This can be empty is there are no parameters.
Ques 8- what do you understand by early binding and static binding?
Ans :- the compiler at compile time knows the number and type of arguments. The compiler
selects the appropriate function for a call at the compile time itself. This is known as early
binding or static binding.
Ques 9- What is the role of static keyword in function prototype
Ans:- the keyword static signifies that function can be called without creating its object.
Ques 10. Give the difference between pure and impure function ?
Ans:- Pure :- These types of functions uses the object received for various process but do not
changes the state of the object.
Impure:- this type of functions uses the object received for various processes as well as changes
the state of the object.
Quest 11. How does a function declaration different form a function call?
Ans:- Type specifier is mentioned in function declaration which is absent in function call.
Function declaration should not end with a semicolon but function statement should end with a
semicolon.
Ques 12:- What is function prototype?
Ans :- A function prototype is and interface to the compiler. It is the first line of the function
definition that tells the program about the type of the value returned by the function and the
number and type of parameters.
Ques 13- What do you mean by the term “access specifier”?
Ans:- It means the type of access to the function .i.e. from where and how the function can be
called.
Ques 14 What are the condition which must satisfy to implement function overloading?
Ans:- To implement function overloading function signature must be different in either of three
ways
i. Number of the arguments
ii. Data type of the arguments
iii. Sequence of the arguments

2
FUNCTIONS NOTES FOR GRADE 9

Ques 15 Define an impure function. [2006]


An impure function takes primitive data types or object as arguments and modifies the state of
the received data or object .
Ques 16 Explain the function of return statement. [2006]
There are two functions performed by the return statement.
i. It causes the termination of the execution of the function in which it is written.
ii. It may also return a value to the calling function.

POINT TO REMEMBER
1. Functions are methods that contain codes to perform a specific task and returns values
for further computation.
2. Functions may be categorized as pure and impure functions.
3. Pure functions, also called accessors, are used for getting data for an object.
4. Accessors begin with term get to indicate that they receive values.
5. Impure functions, also called mutators or updaters are used for changing the object’s
state.
6. Mutators usually begin with the term set to indicate that they reset the values of the
object.
7. Every function has a unique signature: its name, return type and a list of parameters.
8. More than one function bearing same name with different parameters is
called function overloading.
9. Primitive variables store the values directly in the memory.
10. Object variables also called reference variables store only the reference (value of the
memory location).
11. Values are passed though arguments to the function.

Anda mungkin juga menyukai