Java: Difference between classes and objects
Java is an object oriented language. This means like unlike other languages such as FOTRAN, Object oriented languages organize the data and the commands come later. In this case java organizes data by use of classes and objects. (Cadenhead & Lemay, 2007) In other words java programs conceptualize a group of objects that work together. Therefore the use of classes in java comes about as it is the template used to create an object. However classes and object are not similar as they have certain differences. First of all class is a template, blueprint or contract that defines what an object’s data field and method will be whereas an object is an instance of a class. (Liang, 2011) Unlike objects classes have special methods called constructors which initialize data fields of objects. Also a class defines the abstract characteristic of a thing i.e. its properties and behaviors whereas an object only provides for a replication of an existing definition in this case the class since it is not self defining. It is also worth noting that, unlike classes’ objects cannot be inherited, that is its traits cannot be passed from one object to another. (Cadenhead & Lemay, 2007) In contrast to objects, related classes can be organized into packages. This is not so the case with objects as instances cannot be grouped together.
Cadenhead, R., & Lemay, L. (2007). Sama Teach Yourself Java in Java 6 in 21 Days. Indianapolis: Sams Publishing. Liang, Y. D. (2011). Introduction to Java programming. Boston: Prentice Hall.
Please join StudyMode to read the full document