Java Terminology
This page is a preparation resource for your Project 1 code review. The code review asks you to walk through your code using correct Java terminology. If you already understand a concept, this page gives you the right word to use when describing it.
You do not need to memorize definitions. The goal is to feel comfortable using these terms naturally while talking through your code.
class
A blueprint that defines the structure and behavior of objects. Your project is made up of one or more classes.
Example: FileSummaryAnalyzer is a class.
object
A specific thing created from a class at runtime. Your program works by creating and using objects.
Example: When you write new FileSummaryAnalyzer(), you are creating an object.
instance
Another word for object. When you create an object from a class, that object is called an instance of that class.
Example: "This FileSummaryAnalyzer instance holds the data for one file."
instance variable
A variable declared inside a class but outside any method. Each object (instance) of the class has its own copy of instance variables. They hold the state of an object.
Example:
private List<String> lines; // instance variable
local variable
A variable declared inside a method. It only exists while that method is running and cannot be accessed from outside the method.
Example:
public void process() {
int count = 0; // local variable
}
method
A named block of code inside a class that performs a specific task. You call a method to run that code.
Example: readFile() and printSummary() are methods.
method call
The act of invoking a method so it runs. You call a method by writing its name followed by parentheses, passing any required arguments.
Example: analyzer.readFile("data.txt"); is a method call.
parameter
A variable listed in a method's definition that receives a value when the method is called. Parameters describe what a method needs in order to do its work.
Example:
public void readFile(String fileName) { // fileName is a parameter
argument
The actual value you pass to a method when you call it. Arguments fill in the parameters.
Example: readFile("data.txt") -- "data.txt" is the argument.
return type
The data type a method sends back after it finishes. If a method does not send anything back, its return type is void.
Example: public int getLineCount() has a return type of int.
return value
The actual value a method sends back when it finishes running.
Example: If getLineCount() returns 42, then 42 is the return value.
constructor
A special method used to create and set up a new object. It has the same name as the class and no return type.
Example:
public FileSummaryAnalyzer() { // constructor
lines = new ArrayList<>();
}
exception
An error that occurs while a program is running. Java uses exceptions to signal that something went wrong, such as a file not being found or invalid input.
Example: FileNotFoundException is an exception thrown when a file cannot be located.
try-with-resources
A Java statement that automatically closes resources (like file readers or scanners) after the try block finishes, even if an exception occurs. It replaces the need to manually close resources in a finally block.
Example:
try (Scanner scanner = new Scanner(file)) {
// scanner is automatically closed when this block ends
}
interface
A contract that defines what methods a class must have, without providing the implementation. A class that uses an interface agrees to provide those methods.
Example: List is an interface. It defines methods like add() and get(), but does not say how they work internally.
concrete class
A class that provides actual implementations for all its methods. You can create objects directly from a concrete class.
Example: ArrayList and TreeSet are concrete classes. You cannot create an object from List directly, but you can from ArrayList.
implementation
The actual code inside a method that makes it work. When a class implements an interface, it provides the implementation for each required method.
Example: ArrayList is an implementation of the List interface.
inheritance
When one class extends another, it inherits the parent class's methods and variables. The child class can use or override them.
Example: If AnalyzerBase is a parent class, a class written as class FileSummaryAnalyzer extends AnalyzerBase inherits from it.
encapsulation
The practice of keeping an object's internal data private and only allowing access through methods. This protects data from being changed in unexpected ways.
Example: Declaring instance variables as private and providing getLineCount() instead of exposing the variable directly.
access modifier
A keyword that controls where a variable or method can be accessed from. Common access modifiers are public, private, and protected.
Example: private List<String> lines; -- private means only code inside the same class can access lines.
static
A keyword that means something belongs to the class itself, not to any specific object. A static method or variable is shared across all instances.
Example: public static void main(String[] args) -- main is a static method, so Java can call it without creating an object first.
instance method
A method that belongs to a specific object and can access that object's instance variables. Most methods you write are instance methods.
Example: getLineCount() is an instance method. It reads from the object's lines variable.
object reference
A variable that holds the memory address of an object, rather than the object itself. When you assign one object variable to another, both refer to the same object in memory.
Example: FileSummaryAnalyzer analyzer = new FileSummaryAnalyzer(); -- analyzer is an object reference.
ArrayList
A concrete class that implements the List interface. It stores an ordered list of objects and allows duplicates. Elements can be accessed by index.
Example: List<String> lines = new ArrayList<>();
TreeSet
A concrete class that implements the Set interface. It stores unique elements in sorted order.
Example: Set<String> uniqueWords = new TreeSet<>();
List
An interface representing an ordered collection that allows duplicate elements. ArrayList and LinkedList are common implementations.
Set
An interface representing a collection of unique elements (no duplicates). TreeSet and HashSet are common implementations.
Map
An interface representing a collection of key-value pairs. Each key maps to exactly one value. HashMap and TreeMap are common implementations.
Example: Map<String, Integer> wordCount = new HashMap<>();