Function Flashcards

1
Q

Define function

A

A program module used at different instances in a program to perform a specific task

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Advantages of a method

A

Reuses a segment of operations when called upon
Divides a complex task into smaller methods
Occupies less memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Define a method

A

< Access specifier > < return type > < method name > (Parameter list)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Private access specifier

A

Member of only that class can access function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Public Access Specifier

A

Function can be accessed by external class functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Protected Access Specifier

A

Inherited members can access the protected functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Features of Return statement

A

→ At the end of a method
can return only I variable
only one return statement can be used.
No statement is executed after return

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Define “Invoking a method”

A

Process of using a method in a program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Formal parameters

A

Arguments that are passed to the methods. They receive values from the Caller method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Actual parameters

A

Values actually passed to the method during its call from the main () functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Ways of defining a function

A

Value, outcome
Value, no outcome
No value, outcome
No value, no outcome

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the different ways of passing values to a function

A

Pass by value
Pass by reference

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Pass by value

A

Passing a copy of actual parameters to the formal parameters. Any change made in the formals does not reflect on the actuals.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Pass by Reference

A

Passing the reference/ address of an actual parameter to a formal parameter. Both share the same memory location.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Pure Function (AKA accessor method)

A

A function which returns a value to its caller module without changing the state (value) of an object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Impure Functions ( AKA mutator method) .

A

A function that may not return a value but changes the state (value) of an object.

17
Q

What does Java do to impose restrictions on mutator methods?

A

Allows optional inclusion of a modifier along with access specifier while defining methods of a class

18
Q

Static Binding

A

The system finds the best match of function arguments and parameter list during program compilation.

19
Q

Function Overloading

A

Defining a function with same names but different number and types of parameters.

20
Q

Recursive Function

A

A function that calls itself in its body