What is the difference between a class and an object?

A good answer might be:

  • A class is a description of a possible object.
  • An object is a unique instance of a class.
Or you could say that a class is a plan for an object and an object is what results when the plan has been carried out.

Object Oriented Programming

Object-Oriented programming (in Java or in any object-oriented language) consists of two big steps:

  1. Creating the Program.
    • The programmer defines classes that describe future objects that the program will use when it is running.
    • The programmer defines a class that contains the static main() method which is used to start the program running.
  2. Running the Program.
    • The program is compiled into bytecode.
    • The java interpreter looks for a static main() method and starts running it.
      • Since the method is static, it can start running even though no objects have been created, yet.
    • As the program runs, objects are created and their methods are activated.
      • The program does its work by creating objects and activating their methods.
      • The exact order of object creation and method activation depends on to task to be performed and the input data.

In this view, programming is like assembling a team of human workers to get a job done:

  1. First you plan on the workers you will need.
  2. Then you assemble the team and go to work.

QUESTION 2:

(Thought question:) You have decided to open a pizza delivery business, consisting of yourself and several employees. What job descriptions will these employees have?

Click Here after you have answered the question