JAVA METHOD PART 1 Flashcards

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

A method is a group of code that performs a
specific _______ or ______.

A

Task or Operation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
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
4
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
5
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
6
Q

Determines who can use the class, method,
or field (e.g., public, private).

A

accessSpecifier

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

The name of the method, written in
camelCase (e.g., calculateSum).

A

methodName:

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

Input values that the method can accept. A method can have zero or more parameters, each with a data type and name.

A

parameter

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

The code inside curly braces {} that defines
what the method does.

A

method body

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

If the method has a return type (not void), it must include a return statement followed by the value to be sent back.

A

return statement

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

Can be accessed from any class.

A

Public

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

Can only be accessed within the class where it is defined.

A

Private

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

Accessible within the same package or by subclasses in different packages.

A

Protected

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

Automatically applied if no specifier is mentioned. Accessible only within the same package.

A

Default

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

The ____________ in Java includes the method name and its parameter list.

A

method signature

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

The method signature in Java includes the method
name and its ____________.

A

parameter list

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

The parameter list consists of:
1.____________
2.____________
3.____________

A
  1. The number of parameters.
  2. The type of parameters.
  3. The order of parameters.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

If there are ____________, they are separated by commas.

A

multiple parameters

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

If there are multiple parameters, they are separated by _________.

A

commas

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

If there are no parameters, use an empty pair of
__________.

A

parentheses ()

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

Parameters allow you to pass _______ to the method

A

values

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

Parameters are declared inside the parentheses after the ____________.

A

method name

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

The scope of parameters is limited to the ___________.

A

method
body

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

Parameters are optional, and a method can have _______ parameters.

25
The method body is a block of code that contains: 1.)_________ to perform tasks. 2.)_________ and __________ (if needed). 3.)___________ (optional, depending on the method type).
The method body is a block of code that contains: STATEMENTS to perform tasks. LOCAL VARIABLES and LOCAL CLASS (if needed). A RETURN STATEMENT (optional, depending on the method type).
26
If the return type is void, the method performs a task without returning any _____.
value
27
Such methods do not include a ______ statement
return
28
If the return type is a data type (e.g., int, float, double), the method must return a _____ to the caller.
value
29
The ______ cannot end without executing a return statement.
method
30
The method provides a piece of data that can be used elsewhere in the program.
Return a value
31
The method directly displays information (e.g., on the screen).
Print output
32
These are methods created by programmers to perform specific tasks. They are designed to meet the unique requirements of a program.
User-Defined Methods
33
System-Defined Methods: Also called ________ or ________ methods.
built-in or library
34
Also called built-in or library methods. 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.
System-Defined Methods
35
What are the two basic types of methods?
1. System-Defined Methods 2. User-Defined Methods
36
This is a custom method that takes two integers as input and returns their sum.
add (int num1, int num2):
37
This is a custom method that checks if a number is even.
isEven (int number)
38
This is a system-defined method from the Math class that calculates the square root of a number.
Math.sqrt(double a)
39
This is a system-defined method from the String class that returns the length of a string.
String.length()
39
Used in method declarations to show that the method does not return any value.
Void Keyword
40
A ____ method acts but does not return a result that can be used in an expression.
void
41
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
42
When ______ is executed, the method stops immediately, and control goes back to the caller.
return
43
Methods with a ________ (e.g., int, String, double) must use return to send a value back
return type
44
If a method has a return type (e.g., int, String), it must return a _____ of that type.
value
45
Act as placeholders for values that are passed to a method when it is called.
Method Parameters
46
Act as __________ for values that are passed to a method when it is called.
placeholders
47
The actual values passed are called ___________.
arguments
48
Parameters and arguments make methods ________ and _________ for different situations.
flexible and reusable
49
__________ and __________ make methods flexible and reusable for different situations.
Parameters and arguments
50
Variables are listed in the method signature to accept input values.
Method Parameters
51
The actual values are passed to the method when it is called.
Method Arguments
52
Allows you to define multiple methods in the same class with the same name but different parameter lists.
Method Overloading
53
The compiler identifies the correct method based on the _______, _______, and ______ of parameters.
number, type, and order of parameters
54
The __________ identifies the correct method based on the number, type, and order of parameters
compiler
55
All _________ methods must have the same name
overloaded
56
In _______________, Methods must differ in the number, type, or order of parameters.
Overloading method
57
_________ methods can have the same or different return types, but the return type alone cannot distinguish methods.
Overloaded