Java Methods Flashcards

(89 cards)

1
Q

_________ in Java are like the basic units or building blocks of a Java program.

A

Methods

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

Methods in Java are like the ______ or building
blocks of a Java program.

A

basic units

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

Methods in Java are like the basic units or ________ of a Java program.

A

building
blocks

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

A _______ is a group of code that performs a
specific task or operation.

A

method

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

A method is a __________ that performs a
specific task or operation.

A

group of code

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

A method is a group of code that performs a
_________ or operation.

A

specific task

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

A method is a group of code that performs a
specific task or _________.

A

operation

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

a _______ is a collection of
statements that work together to complete
a particular job.

A

method

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

a method is a ________ that work together to complete
a particular job.

A

collection of
statements

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

a method is a collection of statements that ____ ________ to complete a particular job.

A

work together

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

a method is a collection of statements that work together to _______________.

A

complete a particular job

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

________ are used to carry out specific actions
and are sometimes called functions.

A

Methods

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

Methods are used to carry out specific actions
and are sometimes called _______.

A

functions

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

Methods are used to _____ _____ _______ ______
and are sometimes called functions.

A

carry out specific actions

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

In Java, a ________ runs only when it is called from
another _________.

A

method

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

The ________ is the starting point of a Java
program, and it is the first method executed by
the JVM (Java Virtual Machine).

A

main() method

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

The main() method is the ______ ________ _______ _______, and it is the first method executed by the JVM (Java Virtual Machine).

A

starting point of a Java
program

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

The main() method is the starting point of a Java program, and it is the _______ executed by
the JVM (Java Virtual Machine).

A

first method

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

The main() method is the starting point of a Java program, and it is the first method executed by the _____________________.

A

JVM (Java Virtual Machine)

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

The main() method is the starting point of a Java
program, and it is the first method executed by
the JVM (________________).

A

(Java Virtual Machine)

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

_______ in Java are reusable blocks of
code designed to perform specific tasks.

A

Methods

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

Methods in Java are _____ _____ ___ _____ designed to perform specific tasks.

A

reusable blocks of
code

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

Methods in Java are reusable blocks of
code designed to______ _____ ____.

A

perform specific tasks

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

They help _______, complex programs into smaller, easier-to-handle parts.

A

break large

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
They help break large, _____ ______ into smaller, easier-to-handle parts.
complex programs
26
They help break large, complex programs into _________, easier-to-handle parts.
smaller
27
They help break large, complex programs into smaller, __________ _____.
easier-to-handle parts
28
They keep your code _________ and_______.
organized neat
29
They keep your _____ organized and neat.
code
30
You can ____ _____ ________ ______ in different parts of your program.
reuse the same method
31
You can reuse the same method in different parts of your __________.
program
32
They save ______ and help reduce mistakes in your code.
time
33
They save time and _________ ___________ ______ in your code.
help reduce mistakes
34
_______________: Determines who can use the class, method, or field (e.g., public, private).
accessSpecifier
35
_________: Specifies the type of value the method returns. If no value is returned, the keyword void is used.
returnType
36
_________: The name of the method, written in camelCase (e.g., calculateSum).
methodName
37
________: Input values that the method can accept. A method can have zero or more parameters, each with a data type and name.
parameter
38
___________: The code inside curly braces {} that defines what the method does.
method body
39
_______________: If the method has a return type (not void), it must include a return statement followed by the value to be sent back.
return statementt
40
_________: Can only be accessed within the class where it is defined.
Private
40
________: Can be accessed from any class.
Public
41
___________: Accessible within the same package or by subclasses in different packages.
Protected
42
_________: Automatically applied if no specifier is mentioned Accessible only within the same package
Default
43
The _________ __________ in Java includes the method name and its parameter list.
method signature
44
The method signature in Java includes the method _______ and its _______ ________.
name parameter list
45
The parameter list consists of:
The number of parameters. The type of parameters. The order of parameters.
46
If there are multiple parameters, they are separated by ___________.
commas
47
If there are ____ _______, they are separated by commas.
multiple parameters
48
If there are no parameters, use an __________________
empty pair of parentheses ()
49
_________ allow you to pass values to the method.
Parameters
50
___________ are declared inside the parentheses after the method name.
Parameters
51
Parameters are declared inside the parentheses after the __________.
method name
52
Parameters are declared inside the___________ after the method name.
parentheses
53
The scope of parameters is limited to the ____________.
method body
54
Parameters are ________, and a method can have zero parameters.
optional
55
Parameters are optional, and a method can have ___________.
zero parameters
56
The _________ is a block of code that contains: Statements to perform tasks. Local variables and local classes (if needed). A return statement (optional, depending on the method type).
method body
57
The method body is a __________ that contains: Statements to perform tasks. Local variables and local classes (if needed). A return statement (optional, depending on the method type).
block of code
58
The method body is a block of code that contains: 1.________ to perform tasks. 2.________ and 3.___________ (if needed). 4.________ (optional, depending on the method type).
1.Statements 2.local variables 3.local classes 4.A return statement
59
If the ____________ is void, the method performs a task without returning any value.
return type
60
If the return type is ______, the method performs a task without returning any value.
void
61
If the _________ is a data type (e.g., int, float, double), the method must return a value to the caller.
return type
62
If the return type is a data type (e.g., int, float, double), the method must return a value to the______.
caller
63
If the return type is a __________ (e.g., int, float, double), the method must return a value to the caller.
data type
64
The method cannot end without executing a ____________.
return statement
65
The _______ cannot end without executing a return statement.
method
66
___________ can do two main things: Return a value: The method provides a piece of data that can be used elsewhere in the program. Print output: The method directly displays information (e.g., on the screen).
Methods
67
Methods can do two main things: ____________: The method provides a piece of data that can be used elsewhere in the program. Print output: The method directly displays information (e.g., on the screen).
Return a value
68
Methods can do two main things: Return a value: The method provides a piece of data that can be used elsewhere in the program. _____________: The method directly displays information (e.g., on the screen).
Print output
69
There are two basic types of methods
1.System-Defined Methods 2.User-Defined Methods
70
1.System-Defined Methods: Also called built-in or library methods. These are____________ available in __________________ (part of the JDK). You can use them directly without writing the code yourself.
pre-written methods Java’s standard libraries
71
1.System-Defined Methods: Also called ________________. These are pre-written methods available in Java’s standard libraries (part of the JDK). You can use them directly without writing the code yourself.
built-in or library methods
72
User-Defined Methods: These are methods created by _______ to perform specific tasks. They are designed to meet the unique requirements of a program.
programmers
73
___________ - Used in method declarations to show that the method does not return any value.
Void Keyword
74
_________- Used to exit a method and, if needed, return a value to the caller. It is used in methods that have a return type (not void).
Return Keyword
75
When ______ is executed, the method stops immediately, and control goes back to the caller.
return
76
When return is executed, the method stops immediately, and _______ goes back to the _________.
control caller
77
The ___________ must match the ______________ in the method definition.
order of arguments order of parameters
78
The __________ must match the data type of parameters.
data type of arguments
79
The data type of arguments must match the ____________.
data type of parameters
80
Use ____ and _____________ for parameters to improve code readability and maintainability.
clear meaningful names
81
Use clear and meaningful names for parameters to improve code ______ and __________.
readability maintainability
82
The _________ identifies the correct method based on the number, type, and order of parameters.
compiler
83
The compiler identifies the correct method based on the ______,_______ and ____________.
number type order of parameters
84
______________ Allows you to define multiple methods in the same class with the same name but different parameter lists
Method Overloading
85
All ___________ must have the ______________.
overloaded methods same name
86
Methods must differ in the __________, ____________, or _______________.
number type order of parameters
87
Overloaded methods can have the same or different __________, but the return type alone cannot distinguish methods
return types
88
Purpose of Method Overloading
Improve Readability Provide Flexibility Avoid Repetition