java methods Flashcards
(17 cards)
blocks of code that perform specific tasks and
are part of a class.
methods
They allow code reusability and modularity by
defining a single block of code that can be executed multiple times
by “____” the method.
calling
they are used to divide and sort Functionalities within in a
class so that the code will readable even if its long.
methods
defines the visibility of the method (public,
private, protected, no modifier(Default)).
Access Modifier
The data type of the value the method returns.
return type
Use
___ if the method does not return a value.
void
Name of the Java method. Used to call the method.
Method Name:
variable passed to the method for processing.
Parameters
parameter is
optional
A ___ belongs to the class rather than any instance (object). Therefore, it can be
called directly using the class name, without creating an object.
static method
To call an ___, you first need to create an object of the class where the
method is defined. Then, use the object to call the method.
instance method
The ___ keyword is used to return a value from a method. It is required when a method produces a result. The type of the returned value must match the method’s
specified type.
return
- Use a ___ if the method returns a value (e.g., int, double, String).
specific data type
use ___ if the method does not return anything
void
_____ in Java occurs when two or more methods in the
same class have the same ___ but different ___.
Method overloading, name, parameters
___ allows
you to define multiple behaviors for a method while maintaining readability.
Overloading