Concepts of object oriented programming
- Abstraction
- Encapsulation
- Object and Classes
- Polymorphism
- Inheritance
Abstraction:-
Suppose customer went to a shop to purchase television.
What are the details provided by seller ?
Brand, Model,Size,Features of television,
What are the details which are not given to customer?
How it works how many wire are used to make television and internal components.
Lets find out the concept here which is
Abstraction:-Which says process of find the essential details and ignoring the non essential details from end user.
Helps simplify the problem and make easy to understand complex systems.
Encapsulation:-
Think of if customer want to use television what should do?
He/She simply switch on he button or use remote to watch the Television.
The remote encapsulate all the complex working and provide a simple interface for operating the television
Lets find out the concept here which is
Encapsulation:which says A mechanism of hiding internal details and provide a simple interface which ensure that the object can be used without knowing the internal details.
En = "In a"
capsulation = capsule.
Object & Classes
Lets take an entity,say Television What are the attribute and some activities of Television?
Attributes:Brand,model,size.
Activities:It is used to watch movies ,cricket.
Lets take some other category .says customer so what are the attribute and activities associated with customer
Attributes:Customer id ,name,address
Activities:adding,updating,editing of customer data
How can the attributes and activities combined?
With the help of Classes and objects
When the attributes and activities on the attributes are combined into single unit is called class and the instance of class is object.
Inheritance
Consider a retails store application what are the different categories of customers?
Regular customers and Privileged customers
What are the common attributes of Regular and Privileged customer?
Customer's id,name,address,mobile number.
List difference between customers
Regular customer get discount based on products
Privileged customer get gift based on membership card
Inheritance: Is a mechanism which allows to define generalized characters and behavior and also create specialized one.Specialized one tends to inherit all the characters and behavior of generalized ones
Customer is generalized once and Regular and Privileged customer are specialized once.
Classes are arranged in tree like structure
Customer is Base class
Regular and Privileged customers are Derived classes also called base classes.
Inheritance also
promotes reuse. You don't have to
start from scratch when you write a new program. You can simply reuse an
existing classes that have behaviors similar to what you need in
the new program.
Polymorphism:
Consider same application Customer has purchased items and bill is to be calculated is the bill calculation of both type of customer is same?
No. because Regular customer get discount and Privileged customer get gifts
Is the bill is calculated for all customer ?
Yes. calculation of bill is done for all the customers but formula of calculation is different.
Polymorphism: Refers to the ability of an object to behave differently in different situations
Poly = Many
Morph = Forms
Ability to take different form is called Polymorphism
We will cover one more concept here which is Access Specifiers
Access Specifiers
Used to expose or hide attributes in class
Consider same application Customer has purchased items and bill is to be calculated is the bill calculation of both type of customer is same?
No. because Regular customer get discount and Privileged customer get gifts
Is the bill is calculated for all customer ?
Yes. calculation of bill is done for all the customers but formula of calculation is different.
Polymorphism: Refers to the ability of an object to behave differently in different situations
Poly = Many
Morph = Forms
Ability to take different form is called Polymorphism
We will cover one more concept here which is Access Specifiers
Access Specifiers
Used to expose or hide attributes in class
- Public : Accessible to all classes.
- Protected: Accessible within the class and its sub-classes
- Private: Accessible only within the class
- Default: Accessible within class itself and package in which defined

0 comments :
Post a Comment