Java OOP – Objects/Classes/Attributes
August 6, 2020 1 min read

In the last article we discussed about an Introduction on Java OOP. Today’s article is on the topics Objects, Classes and Attributes.
Objects
In the real world you can see many objects such as animals, humans, and vehicles etc. All these have a state and a behavior.
Software Objects also have a state and a behavior. State is stored in fields and behavior is shown via methods.
A object is an computer representation of some real world thing or event.
Example: If you own a vehicle, the computer would store the name of the model, vehicle Identification number (VIN) and the motor type. Objects can have both attributes (such as model, VIN, and motor type) and behaviors (such as “lights go on” and “lights go off”).
Classes
A class is a blue print (template) of similar objects. Objects are created from classes. A class defines the set of shared attributes and behaviors found in each object in the class.
Example: Every automobile have attributes for Make/Model, VIN, and Engine.
The programmer must define the classes in the program. When the program runs, objects can be created from the established class. The term instantiate is used when an object is created from a class.
Example: A program could instantiate the “Jeep Wrangler” as an object from the class “Automobile”.
Attributes
Class Attributes are variables within a class. A class can contain any of the following variable types.
- Local variables – Variables defined inside methods, constructors or blocks.
- Instance variables – Variables within a class but outside any method.
- Class variables – Variables declared within a class, outside any method, with the keyword “static”.
The next article will teach you about java constructors.
Thank you.


