0% found this document useful (0 votes)
29 views3 pages

Ict 10 Notes

The document discusses object oriented programming concepts like classes, objects, inheritance, polymorphism, encapsulation and abstraction. It explains the difference between object oriented and procedural programming. It also describes different types of inheritance like single, multiple, hierarchical and multi-level inheritance giving examples.

Uploaded by

Ayah Siplon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Ict 10 Notes

The document discusses object oriented programming concepts like classes, objects, inheritance, polymorphism, encapsulation and abstraction. It explains the difference between object oriented and procedural programming. It also describes different types of inheritance like single, multiple, hierarchical and multi-level inheritance giving examples.

Uploaded by

Ayah Siplon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ICT 10 NOTES ➣ A class is a collection of objects or you

can say it is a blueprint of objects


defining the common attributes and
Introduction to Object Oriented behavior. Now the question arises, how do
Programming in Python you do that?

➣ Object oriented programming is a way ➣ Class is defined under a “class”


of computer programming using the idea Keyword.
of “objects” represents data and
methods. It is also an approach used for Example:
creating neat and reusable code instead
of a redundant one.

Difference between Object-oriented and


Procedural Oriented Programming

Object-oriented Procedural-oriented Object-Oriented Programming


Programming Programming (Pop) Methodologies:
(OOP)
❐ Inheritance
It is a bottom-up It is a top-down
approach approach ❐ Polymorphism
❐ Encapsulation
Program is Program is divided ❐ Abstraction
directed into into functions
objects
Inheritance
Make use Access Doesn’t use Access ➣ Ever heard of this dialogue from
modifiers modifiers relatives “you look exactly
‘public’, ‘private’, like your father/mother” the
‘protected’
reason behind this is called
It is more secure It is less secure ‘inheritance’.
➣ From the Programming aspect,
Object can move Data can move It generally means “inheriting or
freely within freely from functions
transfer of characteristics from
member to function within
functions programs parent to child class without any
modification”. The new class is
It supports It does not support called the derived/child class and
inheritance inheritance the one from which it is derived is
called a parent/base class
What are classes and Objects?
Types of Inheritance OUTPUT: 22
Multi-level Inheritance

Single Inheritance

➣ a derived class is created from another


derived class.
➣ In the given example, class c inherits
the properties and behavior of class B and
➣ created from a single base class B inherits the properties and
➣ In the given example, Class A is the behavior of class B. So, here A is the
parent class and Class B is the child class parent class of B and class B is the parent
since Class B inherits the features and class of C. So, here class C implicitly
behavior of the parent class A. inherits the properties and behavior of
class A along with Class B i.e there is a
Example: multilevel of inheritance.

Example:
Class employee1()://This is a parent
class
def__int__(self,name,age,salary). Class employee1()://Super class
self.name = name def__int__(self,name,age,salary).
self.age = age self.name = name
self.salary = salary self.age = age
self.salary = salary
Class childemployee(employee1)://This
ia a child class Class childemployee1(employee)://First
def__int__(self,name,age,salary,id). child class
self.name = name def__int__(self,name,age,salary,id).
self.age = age self.name = name
self.salary = salary self.age = age
self.id = id self.salary = salary
emp1=employee1(‘harshit’,22,1000) Class
print(emp1.age) childemployee2(employee)://Second
➣ enables more than one derived class to
child class
def__int__(self,name,age,salary,id). inherit properties from a parent class.
self.name = name ➣ In the given example, class A has two
self.age = age children class B and class D. Further, class
self.salary = salary B and class C both are having two children
Emp1 = employee ('harshit',22,1000) - class D and E; class F and G respectively.
Emp2 = childemployee1('arjun',23,2000)

print(emp1.age) Advantages of Inheritance


print(emp2.age) ➞ Reduce code redundancy.

OUTPUT: 22,23
➞ Provides better code reusability.

Multiple Inheritance ➞ Reduces source code size and


improves code readability.

➞ The code is easy to manage and


divided into parent and child classes.

➞ Supports code extensibility by


overriding the base class functionality
within child classes.
➣ a derived class is created from more Disadvantages of Inheritance
than one base class. This inheritance is
not supported by .NET Languages like C#,
F#, etc., and Java Language. ➞ In Inheritance base class and child class,
➣ In the given example, class c inherits both are tightly coupled. Hence If you
change the code of the parent class, it will
the properties and behavior of class B and
affect all the child classes.
class A at the same level. So, here A and
Class B both are the parent classes for ➞ In a class hierarchy, many data
Class C. members remain unused and the
memory allocated to them is not utilized.
Hence it affects the performance of your
program if you have not implemented
Hierarchical Inheritance
inheritance correctly.

You might also like