User-Defined Methods Flashcards
What is a program?
It is a set of instructions given to the computer to solve a particular problem
How are instructions in a program specified,
In forms of methods in Java
What are methods known as in other programming languages?
functions, procedures, modules, subroutines or sub-programs
Where do the methods exist?
Inside a class
Name the two types of methods
- System defined methods
2. User Defined Methods
What are system defined methods??
The methods defined by the developers of Java
Give other names for system defined methods
Library methods or built in methods
What are user-defined methods?
The methods defined by the user. They are defined as per the need of the user to create customised and reusable blocks of code
Give the advantages of methods
- They provide the means to avoid duplication of the code and help in code reusability
- They help divide complex programs into manageable code blocks
- They help in understanding the flow of a program
- They help in improving the readability of the code
- They make debugging of the code easier
When are the methods defined inside the class?
Immediately after the member variables
Give the syntax of a method definition
[access modifier] type method-name ([parameter list])
{
method body;
}
What is the first line of the method definition called?
Method prototype or method header
Name the five main parts a method definition can be divided into
- The method prototype - begin w/ a.m.
- Data returned if any valid java d.t
- Method name can be any identifier
- Parameter list -sequence of d.t and identifier pairs
- Statements must be within method body
What may the method prototype begin with?
An access modifier
What are the forms the access modifier can take?
Public, private or protected