Each of the following ideals of Object orientated programming
each have a significant part in making OOP as without each of these
characteristics it would not function quite the same way.
Encapsulation is used to describe the idea of bundling data and
methods that work on that data within one unit, an example of encapsulation in
Java is a class.
primary benefit of encapsulation is the ability to modify implemented code
without breaking the code of others who use it.
allows for data hiding to occur this is because it enables attributes of the
class to be kept private and make use of getter and setter methods in order to
modify the program.
This makes the code more maintainable and
gives a greater degree of flexibility
Inheritance is the principle of
creating a sub-class from a super-class or creating a child class from a parent
The cornerstone of the principle is
the fact that the child class retains all of the characteristics of the parent
class while making modifications or extension to this.
A subclass can access all of the
protected and public attributes of its superclass.
is used to make the code more streamlined as it prevents the same section of
code being re-written and applied to each subclass this can be seen in
While some languages support
inheritance from multiple parent classes while Java only allows for single
inheritance. This can reduce confusion in reviewing the program as each object
will on have at most one set of parental attributes.
is the capability of a method to do different things based on the object that
it is acting upon.
means that a method can have the same code which when acted upon can have a
variety of effects
example of this is having a class called Animal with a method for animal sound,
this method can be applied to both a cat and a dog object with different
The purpose of this
is to make the program more effiecnt, this is because by writing a general
section of code that can be applied to multiple objects which share
characteristics like subclasses in a superclass.