Glossary
Class
A blueprint or template that defines the structure (data) and behavior (methods) for objects of a certain type.
Example:
The Car class defines that all car objects will have a make, model, and a startEngine() method.
Constructor
A special method within a class used to create new objects (instances) of that class and initialize their instance variables.
Example:
new Book("The Hobbit", "J.R.R. Tolkien") calls the constructor to create a new Book object with a title and author.
Dot operator (.)
Used to access the instance variables or call the methods of a specific object.
Example:
myCar.getModel() uses the dot operator to call the getModel() method on the myCar object.
Instance
A specific, concrete object created from a class blueprint. Each instance has its own unique set of data based on the class's definition.
Example:
If Dog is a class, then myDog created as new Dog("Buddy") is an instance of the Dog class.
Instance Variables
Variables declared within a class but outside any method, representing the characteristics or data unique to each object (instance) of that class.
Example:
In a Dog class, String breed; and int age; would be instance variables for each individual dog object.
Methods
Blocks of code within a class that define the behaviors or actions that objects of that class can perform.
Example:
A Robot object might have a move() method to change its position or a chargeBattery() method.
Object Instantiation
The process of creating a new object (an instance) from a class using the `new` keyword and a constructor.
Example:
The line Student alice = new Student("Alice", 18, 3.5); demonstrates object instantiation, creating the alice object.
Objects
Complex entities in Java programs that hold data and perform actions. They are specific instances created from a class blueprint.
Example:
In a video game, a Player object might store health and score, and have methods to move or attack.
Primitive Types
Basic data types in Java that store the actual data value directly in memory, such as integers, floating-point numbers, and boolean values.
Example:
int score = 100; declares score as a primitive type variable, directly storing the value 100.
Reference Type
A data type that stores the memory location (address) of the actual data, rather than the data itself. Objects are reference types.
Example:
When you declare String name = "Alice";, name is a reference type variable holding the address of "Alice" in memory.
new keyword
Used in Java to create a new object (an instance) of a specified class by allocating memory for it and calling its constructor.
Example:
Circle myCircle = *new* Circle(5.0); uses the new keyword to create a new Circle object.