Programming Language

Dissimilarities Between An Object And A Class In Java Programming

If you are a programmer, you might know some questions are a serious test to your OOP (Object Oriented Programming) skills. Distinction between an Object and a Class is a sort of those questions.

Comparison:

In programming, Class and object are related to each other, but each is having a distinctive meaning and specification. In general, the term “CLASS” can be defined as, the genuine written segment of a code used to exemplify the performance of any provided class. Therefore, the class is a static chunk of code that has a fix structure and it does not change its features during the execution of a code.

“Object”, On the contrary, can be taken specifically by selecting an element of a specific class. Class is formed with the collections of similar types of objects. In other words, Objects can be classified as the genuine “ILLUSTRATIONS” of a class, with its limited features. In OOP, class is a general code while an object is a chunk or piece of code that is selected from the defined limits of the code.

Example:

To clarify the above mentioned facts about class and object terminologies, a simple but interesting example is described below.

While defining a class and an object, we can take a general class as the specie Animal. We know that all the animals are having bodies, brains, parts of body and etc. These are the features/attributes/characteristics of a class i.e. Animal.

Whereas, an object can be taken as a specific animal. This animal may be a Lion, Tiger, Wolf, or any other specific animal. Every different animal possesses different properties, like how it eats, hunts, sleeps, works, lives etc. Therefore, the difference between the objects as the animals are different in certain characteristics but they are not different in their general concepts as they are all animals and none of them can be said to be a bird or plant.

Thus, in programmer’s perspective, it can be said that a CLASS is a general concept, a general file of CODE whereas an object is a limited, specified piece or  element from that code.

 

Leave a Reply