Object and class in Java

When we consider a Java program, it can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what do class, object means.

  • Object − Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behavior such as wagging their tail, barking, eating. An object is an instance of a class.
  •  Class − A class can be defined as a template/blueprint that describes the behavior/state that the object of its type supports.


Live Demo

public class Tester {
   public void message(){
      System.out.println("Hello World!");
   public static void main(String args[]) {
      Tester tester = new Tester();

Here Tester is class and tester is its object.