+ 1

What is an instance?

This question has been asked before, but I don't understand it. Can someone answer it? Thx.

8th Mar 2017, 4:53 PM
René van den Heuvel
René van den Heuvel - avatar
2 Answers
+ 1
An instance is a specific Object that derives it's variables, properties and methods from an Object Constructor. For instance (no pun intended) we could make an Object Constructor called Mammal and provide it with some generalizable properties and methods that we think most all animals that are Mammals possess, such as eat, sleep, walk, etc. Then we can make another object, lets call it elephant and we can assign it as a new Mammal(), and this makes the elephant Object an instance of the Mammal Object constructor. Assuming there are Parameters in the Mammal constructor, we can provide arguments in the elephant instance to correlate with the Mammal( , , ) parameters, then you can also add unique properties and methods to the elephant Object as well.
1st May 2017, 5:04 AM
Matt
Matt - avatar
0
Imagine a class call humans and then you create a variable based on humans model (class). The variable is an instance of humans. Is it better? :o
8th Mar 2017, 6:00 PM
XueFang