ICSE Class 9 Computer Applications
2. Elementary concept of Object and Class
01 Object encapsulate state (attributes) and have behaviour (functions)
An object is an identifiable entity with some characteristics, a state and behaviour.
Eg. Fan is an object.
Its characteristics are : It has motor,some blades and colour.
Its behaviour is : It can rotate air at some speed.
Its state is : It is idle or rotating.
​
02 Examples of real world objects
​
​
​
03 Class as factory of objects
A class is called an object factory because objects are created from a class.
An object is an instance of a class.
​
The following statements create two objects s1 and s2 of the class Student.
Student s1 = new Student();
Student s2 = new Student();
​
So, we have a single class Student but we can create as many objects as we want (like s1, s2, etc.) from that single class.
​
04 Class as a user defined data type
​
Primitive data types are the general and fundamental data types that we have in Java and those are byte, short, int, long, float, double, char, boolean, etc., User defined data types are those that user / programmer himself defines.
​
05 Class may be regarded as a blueprint to create objects
​
Consider a factory which produces car.
They have only a single design of a car but produce multiple cars from that single design.
Things are similar in the world of classes and objects.
There is a single definition of a particular class (like Student) but we can produce many Student objects
(like s1, s2) from that single class.​​
​​




