What is different between instance and object.
What is different between instance and object.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mangesh GPosted Jan 3, 2017, 2:53 AM
Vishal PrajapatiPosted Jan 3, 2017, 10:42 PM
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 SontakkePosted Jan 3, 2017, 3:34 AM