GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

what is the difference between instance and object in oop ?

asked Jul 13, 2015 by Omkar Vikas Patil

3 Answers

 
Best answer

I'll explain it in the simplest way possible: Say you have 5 apples in your basket. Each of those apples is an object of type Apple, which has some characteristics (i.e. big, round, grows on trees).

In programming terms, you can have a class called Apple, which has variables size:big, shape:round, habitat:grows on trees. To have 5 apples in your basket, you need to instantiate 5 apples. Apple apple1, Apple apple2, Apple apple3 etc....

Alternatively: Objects are the definitions of something, instances are the physical things.

answered Jul 14, 2015 by Ankur310794
selected Jul 14, 2015 by kartik

They are same.   "An object is an instance of class"

answered Jul 13, 2015 by learner

Technically, object and instance are not different. An instance is an object in memory. Basically you create objects and instantiate them when you are using them.

   

A unique copy of class which can represent the object in physical memory is an instance.

answered Jul 14, 2015 by Team Geeks
...