Monday, December 12, 2011

Difference between Primitive types and Objects

Primitive Types:
  • Primitives types are loaded in stack.
  • When the primitive is assigned to another primitive type copy is created.
  • Primitive types are not polymorphic, so it cannot be passed as to a method that takes object as a parameter.
Objects:
  • Objects are loaded in heap
  • When object reference is assigned to another object reference,they share the same object
  • Objects are Polymorphic, so they can be passed as a parameter to any method that takes object as parameter.

No comments:

Post a Comment