The document discusses key concepts in object-oriented programming including objects, classes, abstraction, encapsulation, inheritance, and polymorphism. An object represents an instance of a class and contains data fields and methods. Classes define common properties and behaviors for groups of objects. Abstraction hides unnecessary details and shows only essential features to users. Encapsulation binds data and code into a single unit. Inheritance allows new classes to inherit features from existing classes. Polymorphism enables the same operation to behave differently depending on the context.
2. Object
Object is the basic unit of any programming
language.Objects are identified by its unique name.
An object are identified by its unique name.
An object represents a particular instance of a class.
Each instance of an object can hold its relevant data.
An object is a collection of data members and
associated member functions.
3. Classes are data types based on which objects are
created. Objects with similar properties and methods
are grouped together to form a class.
Class represent a set of individual objects
Example 1:
consider a class of cars under which Santro Xing,
Alto andWagonR represents individual objects.
In this context each car object will have its own
model, year of manufacturer,Colour,Top Speed,
Engine power etc.which from properties of the car
class and the associates functions actions that is
4. Object functions like start,move,stop from the
methods of the car class.
No memory is allocated when the class is created.
Memory is allocated when the object is created.
Example 2 : An architect will have blue prints for a
house…those blue prints will be plan that explain
exactly the what properties the house will have and
how they all are laid out. However it is just a blue
print you cannot live in it.
Builders will look at the blue prints and use those
blueprints to make a physical house.
5. They can use the same blue print to make as many
houses they want……each house will have the same
layout and properties.
Each house can accommodate their own families
…so one house might have smiths live in it….and
one house have the Jones live in it.
The blue print is the class….the house is the
object…the people living in the house are data stored
in the object’s properties.
6. Abstraction: Abstraction means showing essential
features and hiding non-essential features to the user
Example: yahoo mail……
When you provide the username and password and
click on the submit button…It will show the
Compose,Inbox,Outbox,Sent mails…..so when u
click on compose it will open…but the user does not
what are the internal operations the internal
actions…that is non-essential things.
TV remote…..Remote is an interface between user
and tv..right which has buttons 0 to 10..on/of etc.
7. But we donot know circuits inside the remote.
Users does not need to know…just he is using
essential things like remote
8. Encapsulation means which binds the data and
code(or) writing operations and methods in a single
unit.
For example : A car is having a multiple parts …Like
steering ,wheels and engine…which binds together to
form a single object that is car…So here multiple
parts of cars encapsulates itself together to form a
single object that is car.
Encapsulation = Abstraction + data Hiding
9. Inheritance: Deriving a new class from the existing
class is called inheritance. Derived class is getting all
the features from the existing class and also
incorporating some new features to the existing class.
Class Address
{
String name;
String doorno;
String streetname;
}
11. Polymorphism: is the ability to take more than one
form that an operation can exhibit different behavior
at different instance depend upon the data passed in
the operation.
We behave differently in front of elders and friends.
A single person is behaving differently at different
time.
A software engineer can perform different task at
different instance of time depending on the task
assigned to hime.He can do coding, testing, and
analyzing ,designing depending on the task assign
and the requirement.