Class describes the abstract characteristics of a "thing" (or Object as we define below), such as the "thing's" characteristics (its attributes, fields, or properties), and the "thing's" behaviors (the things it can do, or methods, operations, or features. It is typically the blueprint for which Objects are to be built on.
For example, a class Dog could consist of traits shared by all dogs, such as eye and fur color (characteristics - aka properties), and the ability to bark and sit (behaviors - aka methods).
A Method, or function as they also reffered to as, is an Object's ability. A German Sheppard, being a dog, has the ability to bark. So "bark()" is one of German Sheppard's methods. The German Sheppard might have other methods as well, such as "sit()", "eat()", or "walk()".
The properties and methods defined by a class are called members.
An Object is a pattern (exemplar) of a class. When a class of a German Sheppard is created, it can inherit from the Dog Class, and therefore has the same properties and methods as its parent Class.
An Instance is the actual Object created at runtime. The set of values of the attributes of a particular object is called its State. The Object consists of state and the behavior that's defined in the object's class.
- Class is designed --> Object inherits from Class during design --> Instance of Object is created at runtime.
No comments:
Post a Comment