What is different between instance and object.
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Mangesh GRank #294 · 8.6K reputationPosted Jan 2, 2017, 9:53 PM EST
Vishal PrajapatiRank #836 · 2.7K reputationPosted Jan 3, 2017, 5:42 PM EST
Anything that is static in a class becomes propery of the class itself. These are things like static variables and static methods.
To use things that belong to the class itself, no instance of that class is required. No object is required.
Objects, on the other hand, are instances of a class. Any non static method defined in a class requires an instance for it to be used.
An example of a method that belongs to a class is the Collections.sort() method. This can be invoked simply by using the actual class.
However, adding an object to a LinkedList actually requires an instance of that class to be created.
So in short, an object is an instance of a class, so objects and instances are the same thing.
Nitin SontakkeRank #264 · 9.6K reputationPosted Jan 2, 2017, 10:34 PM EST