What Is a Class?
Answer:
The class defines abstract characteristics of objects. It provides a structure for objects or a pattern which we use to describe the nature of something (some object). Classes are building blocks of OOP and are inseparably related to the objects. Furthermore, each object is an instance of exactly one specific class.
We are going to give as an example a class and an object, which is its instance. We have a class Dog and an object Lassie, which is an instance of the class Dog (we say it is an object of type Dog). The class Dog describes the characteristics of all dogs whereas Lassie is a certain dog.
Classes provide modularity in object-oriented programs. Their characteristics have to be meaningful in a common context so that they could be understood by people who are familiar with the problem area and are not programmers. For instance, the class Dog cannot have (or at least should not) a characteristic "RAM" because in the context of this class such characteristic has no meaning.
We are going to give as an example a class and an object, which is its instance. We have a class Dog and an object Lassie, which is an instance of the class Dog (we say it is an object of type Dog). The class Dog describes the characteristics of all dogs whereas Lassie is a certain dog.
Classes provide modularity in object-oriented programs. Their characteristics have to be meaningful in a common context so that they could be understood by people who are familiar with the problem area and are not programmers. For instance, the class Dog cannot have (or at least should not) a characteristic "RAM" because in the context of this class such characteristic has no meaning.
No comments:
Post a Comment