Glossary
Access modifier
A keyword that sets the accessibility level for classes, variables, methods, and constructors.
Example:
The *public* keyword in public static int add(int a, int b) means this method can be accessed from any other class.
Boolean method
A non-void method that evaluates a condition and returns either `true` or `false`.
Example:
The *isLoggedIn*() method might return true if a user is authenticated, or false otherwise.
Method name
The identifier used to call or invoke a specific method.
Example:
In public String *getStudentName*(), getStudentName is the method's identifier.
Mismatched return types
A compile-time error that occurs when the type of the value returned by a method does not match the return type declared in the method's header.
Example:
Declaring public int getAverage() but then trying to *return* 15.5; would cause a mismatched return type error.
Non-void method
A method that calculates or retrieves a value and then returns it for use elsewhere in the program.
Example:
The calculateArea(double length, double width) method returns a double representing the area, allowing you to use that calculated value in other parts of your program, like System.out.println("Area: " + shapes.*calculateArea*(10, 5));.
Parameter list
A comma-separated list of input variables (parameters) that a method accepts to perform its task.
Example:
In public int sum(int num1, int num2), *int num1, int num2* is the parameter list, specifying the two integer inputs the method needs.
Reference type
A data type that refers to an object, rather than holding the value directly, such as `String` or `ArrayList`.
Example:
A method returning an *ArrayList*<String> provides a reference to a list of strings, not the list's contents directly.
Return type (dataType)
The type of value that a non-void method is declared to return, which must match the type of the value actually returned by the method.
Example:
In public double calculatePrice(int quantity), *double* is the return type, meaning the method will send back a decimal number.
String method
A non-void method that performs operations on or generates `String` objects and returns a `String` result.
Example:
The *formatName*(String firstName, String lastName) method could return a combined String like "Doe, John".
Unreachable code
Any code within a method that appears after a `return` statement, and therefore will never be executed.
Example:
In a method, return result; followed by System.out.println("Done"); makes the *System.out.println* line unreachable.
return statement
A statement used in a non-void method to terminate its execution and send a specified value back to the caller.
Example:
After calculating a sum, *return* total; sends the total value back to where the method was called.
static keyword
A keyword indicating that a method or variable belongs to the class itself, rather than to any specific object instance of that class.
Example:
The Math.random() method is *static* because you call it directly on the Math class, not on an object like new Math().random().
