HOME

    Learning Objectives

  1. Explain the relationship between a class and an object.
  2. Develop code to declare variables to store reference types.

Notes

Java is an Object Oriented Programming language. A fundamental building block of Java is objects. There are also four pillars of Object-Oriented Programming (OOP). Those are: Abstraction, Encapsulation, Inheritance, and Polymorphism.

What is an object?

It is a user-defined variable. They expand upon primitives to make more complex and malleable variables. There are two main aspects of an object: state and behavior; think nouns and verbs. In the below image, the state is described using the variables unique_id, name, age, city, and gender. The behaviors are described by the methods.

Classes are the templates for creating new objects. You can think of classes like blueprints for houses and the objects are the houses that are built. The blueprint lays out some things that each house will have in common, but as it is built, each house has its own address and other defining details. Java has some built-in classes, some of which have already been seen, such as Math and Scanner. When using Scanner, you also created a Scanner object.

Click on the image below to read a different explanation

Previous Topic Next Topic