Classes & Objects

  • In OOP, each object is independent unit with a unique identity , just as object in a real world.
  • Objects also have characteristics , which are used to describe them.
  • Example – a car can be red or blue ,a mug can be full or empty .These characteristics are called attributes.
  • An attributes describes the current state of an object.
  • In OOP , each object have three dimensions¬† identity , attributes & behaviour.


  • A class describes what the object will be , but is Separate from the Object itself.
  • In other words, classes can be described as blueprints, descriptions or definitions for an object.
  • We can use Same class as an blue prints for creating multiple objects.
  • The first step is to define the class , which then becomes a blue print for object creation.
  • Each class have a name & each is used to¬† define attributes & behaviour
  • Example -Consider a class Person which has Attributes :name , height , weight , gender , age Behaviour: walk , run , jump , speak , sleep .


  • Method defines behaviour. A method is a collection of statements that are grouped together to perform an operation.
  • System.out.println() is an example of a method.
  • We can define our own method .
  • class Myclass{
          //creating a method
          static void sayhello(){
                 System.out.println("Hello World");
          public static void main(String args[]){
                sayhello(); //static method can be called directly without creating object