object & instance

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gaya3
    New Member
    • Aug 2007
    • 184

    object & instance

    Hi all,
    What is the difference between object & Instance in Java??
    Thanks in Advance

    -Hamsa
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by gaya3
    Hi all,
    What is the difference between object & Instance in Java??
    Thanks in Advance

    -Hamsa
    Some believe that an object is a specific/particular form of an instance.
    I believe that an object is an instance of a class.
    What do you believe?

    Comment

    • gaya3
      New Member
      • Aug 2007
      • 184

      #3
      Originally posted by r035198x
      Some believe that an object is a specific/particular form of an instance.
      I believe that an object is an instance of a class.
      What do you believe?
      hi,
      only half i got from ur explanation.. bit confusing...
      it ll be useful if u explain with any example please..

      -Hamsa

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by gaya3
        hi,
        only half i got from ur explanation.. bit confusing...
        it ll be useful if u explain with any example please..

        -Hamsa
        Which part is confusing you?

        Comment

        • dmjpro
          Top Contributor
          • Jan 2007
          • 2476

          #5
          Originally posted by gaya3
          Hi all,
          What is the difference between object & Instance in Java??
          Thanks in Advance

          -Hamsa
          What you have, tell me first.
          Explain with some examples what concept you have already.

          Kind regards,
          Dmjpro.

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            To me 'object' and 'instance' are synonyms; 'instance' sounds a bit spiffier though.
            The class is the blueprint and the object/instance is an instantiation (sic) of the blueprint.

            kind regards,

            Jos

            Comment

            • praveen2gupta
              New Member
              • May 2007
              • 200

              #7
              Originally posted by gaya3
              Hi all,
              What is the difference between object & Instance in Java??
              Thanks in Advance

              -Hamsa
              Hi
              as I understood so far Objects are derived from class and Instance is the process/mechanism which creates an object. Tell me where do you have confussion.

              Comment

              • JosAH
                Recognized Expert MVP
                • Mar 2007
                • 11453

                #8
                Originally posted by praveen2gupta
                Hi
                as I understood so far Objects are derived from class and Instance is the process/mechanism which creates an object. Tell me where do you have confussion.
                You're talking about "instantiat ion" here (the process of creating an instance of
                a class, the instance is synonymous to an "object").

                kind regards,

                Jos

                Comment

                • kreagan
                  New Member
                  • Aug 2007
                  • 153

                  #9
                  Originally posted by gaya3
                  Hi all,
                  What is the difference between object & Instance in Java??
                  Thanks in Advance

                  -Hamsa
                  An instance is an object with state. All pencils have erasers and lead. But one pencil I hold in my hand, this instance of this pencil has a pink eraser and sharp point. My brother's pencil has a blue eraser with ear wax on it (yes, pencils can be used as que tips), bite marks, and a dull point. They are both objects of the same class but different instances.

                  I hope that helps.

                  Comment

                  • JosAH
                    Recognized Expert MVP
                    • Mar 2007
                    • 11453

                    #10
                    Originally posted by kreagan
                    An instance is an object with state.
                    Huh? You're confusing terms here. An object can have state but it needn't; it is
                    still an instance of some class.

                    kind regards,

                    Jos

                    Comment

                    • kreagan
                      New Member
                      • Aug 2007
                      • 153

                      #11
                      Originally posted by JosAH
                      An object can have state but it needn't; it is
                      still an instance of some class.

                      kind regards,

                      Jos
                      An object always have a state of some sort. I might be using the term more abstractly than I should. I see it as something that seperates one instance from another instance. Even a difference in memory address could be considered as a different state, in my mind. Furthermore, all objects have an initialized state even if they don't have instance variables.

                      Comment

                      • JosAH
                        Recognized Expert MVP
                        • Mar 2007
                        • 11453

                        #12
                        Originally posted by kreagan
                        An object always have a state of some sort. I might be using the term more abstractly than I should. I see it as something that seperates one instance from another instance. Even a difference in memory address could be considered as a different state, in my mind. Furthermore, all objects have an initialized state even if they don't have instance variables.
                        I was responding to this:

                        Originally posted by kreagan
                        An instance is an object with state.
                        That implies that an object needn't have state while an instance has state. IMHO
                        an ojbect is an instance; both are a 'realization' of a class. I'm running out of
                        synonyms here.

                        kind regards,

                        Jos

                        Comment

                        Working...