Sunday 23 October 2016


Definition 1
  • Instance of a class is known as an object
  • Instance is a way of allocating the sufficient amount of memory for data members.
Definition 2
  • Group of items exists in single entity is known as an object.
  • We can say single entity means an object variable which holds group of values.
Definition 3
  • Real world entities are called as objects.
Definition 4
  • Logical run time entities are called as objects.
Bulletin points 
  • An object can exists physically in this world but class does not exist.
  • An object does not exist without class but class can exist without object
  • Read again above statement for better understanding.
  • Simply i can say object will come from class.
  • Every object having state, behavior and identity of an object.
  • we can create object by using new keyword.
         Classname objectname = new constructor();
         Student s1 = new Student();
  • Classname(Student) represents the name of the class
  • objectname(s1) represents any java valid variable name.
  • by using new(new) operator we will create an object for class.
  • If constructor(Student()) will exists in class(Student) then at the time of object creation it will be called automatically
  • We will learn clearly about constructor in upcoming chapter.
Why should we create an object?
  • Once if you define any variable or data in java program then immediately memory will be not allocated for that data.
  • If we create an object for that class then memory will be assign to the data.
Program        :       Sample class and object program
Program name :
Output           :        
                            Id is : 1
                            Name is : Mouli
class Demo1
        int id = 1;
        String name = "Mouli";

        public static void main(String args[])
                Demo1 demo1 = new Demo1();
                System.out.println("Id is : ";
                System.out.println("Name is : ";

Compile          :      javac
Run                :      java Demo1
Output            :        
                             Id is : 1
                             Name is : Mouli
Thanks for your time.