Object is the basic unit of object-oriented programming. Objects are identified by its unique name. An object represents a particular instance of a class. There can be more than one instance of an object. Each instance of an object can hold its own relevant data.
An Object is a collection of data members and associated member functions also known as methods.
Classes are data types based on which objects are created. Objects with similar properties and methods are grouped together to form a Class. Thus a Class represent a set of individual objects. Characteristics of an object are represented in a class as Properties. The actions that can be performed by objects becomes functions of the class and is referred to as Methods.
For example consider we have a Class of Cars under which Santro Xing, Alto and WaganR represents individual Objects. In this context each Car Object will have its own, Model, Year of Manufacture, Colour, Top Speed, Engine Power etc., which form Properties of the Car class and the associated actions i.e., object functions like Start, Move, Stop form the Methods of Car Class.
No memory is allocated when a class is created. Memory is allocated only when an object is created, i.e., when an instance of a class is created.
Method is a set of procedural statements for achieving the desired result. It performs different kinds of operations on different datatypes. In a programming language, methods (sometimes referred to as “functions”) are verbs. Lassie, being a Dog, has the ability tobark. So bark() is one of Lassie’s methods. She may have other methods as well, for example sit() or eat() or walk() or save(Timmy).
Within the program, using a method usually affects only one particular object; all Dogs can bark, but you need only one particular
dog to do the barking.