Professional Documents
Culture Documents
Introduction To Object Oriented Programming: Chapter - 1
Introduction To Object Oriented Programming: Chapter - 1
Function 1 DATA f4
f2
f3
POP OOP
Programs are divided into functions Programs are divided into objects
Class: it is a blueprint of an object. It is a set of objects of similar type. A is the data type for
objects. It shows wat object has and how it behaves. It is called an object factory.
Example: animal class. If animal is a class then dog, cat, cow etc.. Can be the objects of it.
The encapsulation is a method of packing the data and functions into a single unit.
data can only be accessed by methods thus making the private fields and their
implementation hidden for outside classes. That’s why encapsulation is known as data
hiding.
Coffee machine
When we press button , machine grinds coffee beans into powder, heats some water and
pours it into coffee powder and then coffee decoction is ready to which it adds milk.
But all these steps are encapsulated together to make coffee when a sing button is pressed.
Here, coffee beans, water, milk are data that we don’t see directly.
Inheritance is a technique of acquiring features of objects from one class to the other class
objects. In other words, it helps in deriving a new class from the existing one.
Example : animal class. It can have variable called colour and method called sound().
If there is another class called Bird, even it may need to have same method because even
birds have sound.
So bird class can use method of animal class by inheritance.
The class that gets inherited is called base class, super class or parent class.
The class that inherits base class is known as derived class, sub class or child class.