Chapter 2 Elementary Concept of Objects and Classes Theory
Chapter 2 Elementary Concept of Objects and Classes Theory
Page | 1
UMESH COMPUTER KENDRA (PH : 9897188951)
Example of Real World Class and Objects:- Let us take and example of
class ‘Car’. The characteristics of class car are its colour, model, price,
fuel_capacity, engine_capacity etc and behaviours of car it can
accelerate, halt etc. Objects of class ‘Car’ can be Alto, I10, I20, Honda
City, Honda Brio, Nano, Creta etc.
The various objects of class ‘Car’ can be created by using the following
statements:
Car nano=new Car();
Car creta=new Car();
Car alto=new Car();
Here ‘new’ is the keyword which is used to allocate memory for the
storage of data and functions belong to an object.
Class is a user defined data type: - The class name becomes the data
type for the instances used in the program. It is such a data type that
includes various predefined data types within it. Hence, the class is
said to be a composite data type.
Page | 2
UMESH COMPUTER KENDRA (PH : 9897188951)
Differences between Object and Class :-
Class Object
It is a unique entity having
It is a template that describe the some characteristics and
details of an object. behaviours, define inside the
class.
It is an object producer and
It is created with the use of the
hence called a blue print for a
‘new’ operator.
set of objects.
It is known as an ‘Instance of a
It is known as an object factory.
Class’
Page | 3
UMESH COMPUTER KENDRA (PH : 9897188951)