1.12 Objects : Instances of Classes
Objects - Instances of Class
Java is an object-oriented programming language. That means that one of the primary ways of organizing our programs is in terms of objects. Objects are a kind of value that combines data and the code that operates on that data into a single unit. Objects are defined in Java by writing classes which provide a blueprint for creating objects of a certain kind, describing the data and code that all instances of that class have.
Sometimes classes and objects are used to model things in the real world, such as if we made a Student class to represent students in a school. Other times classes are just ways of organizing different parts of our programs that may not correspond to anything in the world outside the computer.
But in Java all programs are built out of classes. This is why, as you saw in Unit 1, every Java programs starts with public class: the first thing we have to do when we write a Java program is define at least one class.
What are Objects and Classes?
Objects are instances of these classes, meaning they are created based on the class's blueprint. Each object holds its own data and can perform actions defined by its class methods. For example, if we have created a Student class, then each individual student in the program would be an object of that class, capable of holding attributes like name and age and executing methods such as enroll or drop course.

You can also think of a class defining a new type. Just like you use int to declare variables that can hold an whole number value, you can use Turtle to declare a variable whose value has to be an instance of the Turtle class. And just like the Java compiler will only let you do things with the values of int variables that make sense (like adding and multiplying them), it will only let you do things with values of a Turtle variable that make sense to do with turtles, namely accessing the instance variables and methods defined in the Turtle class.
The following picture has lots of cats (objects of the type cat). They are all different, but they share the same attributes and behaviors that make up a cat. They are all instances of cat with different values for their attributes. Name some of the attributes and behaviors of the cats below. For example, the color (attribute) of the first cat is black (attribute value) and it is playing (behavior).

Definitions:
Attribute or instance variables: define what the object knows about itself
object: a specific instance of the class with defined attributes
class: defines a new data type that is like a blueprint
behaviors or methods: define what the object can do