Principles of Object Oriented Programming:
- Data Encapsulation
- Data Abstraction
- Polymorphism
- Inheritance
Data Encapsulation
This is the default nature of a class. A class encapsulates (combines) some data values (fields or properties) and some operations (methods) related to the data as a pack. This nature can be called as Data Encapsulation.
Data Abstraction:
The nature of "instance" creation is called as "Data Abstraction". This feature is taken from "structures" in C languages. (In ‗C‘ language you can create any no. of structure variables based on one structure. The structure variables act as instances for the structure). In the same way, you can create any no. of instances (objects) for a class.
Polymorphism:
The decision making capacity of the compiler is called "Polymorphism".It is of two types:
- Compile-time Polymorphism:
i) Method Overloading: You can write multiple methods with same name within the same class.
ii) Operator Overloading: You can write multiple definitions for the same operator.
- Run-time Polymorphism:
i) Templates / Generics: You can pass any type of value as an argument to a method.
ii) Interfaces: Contains method declarations only, doesn‘t contain method definitions.
No comments:
Post a Comment