A class is a user-defined data type that encapsulates data and methods that can act upon the data together.
A class can also be defined as a classification/category of objects that have similar attributes and behaviour. For example, Automobile is a category of objects that have similar attributes, such as wheels, engine, doors, shape, color, cylinders etc., and behaviours, such as start, run, move, turn etc. Car is an instance of automobile which has different values for the attributes (4 wheels, one engine, 2 or 4 doors, 4/6/8 cylinders, etc), whereas, a semi-truck is another instance of automobile that has different values for the same attributes (18 wheels, one engine, two doors and so forth). |