JAVA METHOD PART 1 Flashcards
_________ in Java are like the basic units or building
blocks of a Java program
Methods
A method is a group of code that performs a
specific _______ or ______.
Task or Operation
Methods are used to carry out specific actions
and are sometimes called _______.
functions
The __________ is the starting point of a Java
program, and it is the first method executed by
the JVM (Java Virtual Machine)
main() method
Methods in Java are ____________ designed to perform specific tasks
reusable blocks of
code
Determines who can use the class, method,
or field (e.g., public, private).
accessSpecifier
The name of the method, written in
camelCase (e.g., calculateSum).
methodName:
Input values that the method can accept. A method can have zero or more parameters, each with a data type and name.
parameter
The code inside curly braces {} that defines
what the method does.
method body
If the method has a return type (not void), it must include a return statement followed by the value to be sent back.
return statement
Can be accessed from any class.
Public
Can only be accessed within the class where it is defined.
Private
Accessible within the same package or by subclasses in different packages.
Protected
Automatically applied if no specifier is mentioned. Accessible only within the same package.
Default
The ____________ in Java includes the method name and its parameter list.
method signature
The method signature in Java includes the method
name and its ____________.
parameter list
The parameter list consists of:
1.____________
2.____________
3.____________
- The number of parameters.
- The type of parameters.
- The order of parameters.
If there are ____________, they are separated by commas.
multiple parameters
If there are multiple parameters, they are separated by _________.
commas
If there are no parameters, use an empty pair of
__________.
parentheses ()
Parameters allow you to pass _______ to the method
values
Parameters are declared inside the parentheses after the ____________.
method name
The scope of parameters is limited to the ___________.
method
body
Parameters are optional, and a method can have _______ parameters.
zero