The document introduces object-oriented programming (OOP) concepts, contrasting them with procedure-oriented programming (POP). It outlines the types of computer languages, programming paradigms, and the advantages and disadvantages of both POP and OOP. Additionally, it explains the four main principles of OOP: encapsulation, inheritance, data abstraction, and polymorphism, along with their differences from one another.
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
3 views
chapter 1
The document introduces object-oriented programming (OOP) concepts, contrasting them with procedure-oriented programming (POP). It outlines the types of computer languages, programming paradigms, and the advantages and disadvantages of both POP and OOP. Additionally, it explains the four main principles of OOP: encapsulation, inheritance, data abstraction, and polymorphism, along with their differences from one another.
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10
Chapter -1
Introduction to object oriented
programming concept Computer Language: A computer language can be defined as a set of codes and symbols that are used to write computer programs. It is also known as a programming language.
There are mainly two types of computer language:
•Low –Level –Language (LLL) A low level language is a programming language that is machine dependent. Assembly and machine language also known as LLL. •High –Level –Language (HLL) A high level language is a programming language that are used to write program by programmer that are machine independent. Some example of HLL: Java, C#, .Net, C++ etc Programming Paradigms: It is a programming way that are mainly two types. (i) Procedure-Oriented programming(POP) (ii) Object-Oriented programming(OOP)
(i) Procedure-Oriented programming(POP) :
POP follows a top down approach that divides the whole problem into smaller programs known as functions or methods and it gives step – by – step instructions to execute. Example: FORTRAN, COBOL, QBASIC etc Advantages: • It is easy to follow the path of program flow. • A smaller amount of memory is required than other type of coding. Disadvantages: • It is hard to correlate with real world object. • It has global data sharing of functions. If any part of the code is changed then it is necessary to make change in all programs where that function is used. (ii) Object-Oriented Programming(OOP): A programming model that depends on the classes and objects, and gives importance to data rather than function is known as OOP. Example: java, C++, C#, .Net, Python etc Advantages: • It uses the concept of re-usability. • Maintaining and modifying code is much easy. • Inheritance can be used to avoid data redundancy. Disadvantages: • It require more space than POP. • It require intensive testing. Difference B/W POP and OOP: POP OOP
It divides the program It divides the program
into small parts known as into objects. method. Example: C++, java, C++, It follows a bottom-up C# etc approach.
It is less secure. It is more secure
Example: C, COBOL, FORTRAN etc Principles of OOP: There are mainly four principles of OOP paradigm. (i) Encapsulation (ii) Inheritance (iii) Data Abstraction (iv) Polymorphism (i) Encapsulation : It is one of the main concept in OOP. It is also called “information hiding”. Means the wrapping up of data members and methods together into a single u nit is called encapsulation. Example: Methods and variables are enclosed within a unit called class. (ii) Inheritance : Inheritance is the property which allows a child class to inherit some properties from its parent class. In java this is achieved by using extends keyword. The properties with access modifier public and protected can be accessed in child class. Example: (iii) Data Abstraction : It is the property by which the essential features of a class are represented without informing about the background details. The non-essential units are hidden from the user. The main purpose of data abstraction is t o reduce the complexity of a program. (iv) Polymorphism : It comes from the Greek words “poly” means many and “morphe” means forms. It means when one task is performed by different ways i.e. known as polymorphism. Example:
Difference between Abstraction and Encapsulation:
Abstraction Encapsulation It is about hiding unwanted The methods and data are kept details in a single unit Abstraction focuses on what the It hide internal details of how an information object must contain. object does something for security reasons. Issues at design level can be Issues at implementation level solved can be solved