Professional Documents
Culture Documents
• Encapsulation: Encapsulation is a mechanism of wrapping the data members and member functions into
a single unit called class. It binds the data within a class, and no outside method can access the data.
• Polymorphism: Polymorphism consists of two words poly+morph, where poly means many and morphs
means many forms. So we can say one thing and multiple forms.
Polymorphism means having more than one function with the same name but with different
functionalities. Polymorphism is of two types:
1. Static polymorphism /early binding.
2. Dynamic polymorphism /late binding.
• Abstraction:
Abstraction is a technique of showing only essential details without representing the implementation details. If
the members are defined with a public keyword, then the members are accessible outside also. If the members
are defined with a private keyword, then the members are not accessible by the outside methods.
• Inheritance:
Inheritance provides reusability. Reusability means that one can use the functionalities of the existing class. It
eliminates the redundancy of code. Inheritance is a technique of deriving a new class from the old class. The
old class is known as the base class, and the new class is known as derived class.
Different Types of Inheritance
OOPs support the six different types of inheritance as given below :
1. Single inheritance
2. Multi-level inheritance
3. Multiple inheritance
4. Multipath inheritance
5. Hierarchical Inheritance
6. Hybrid Inheritance
Disadvantages of OOP
• Proper planning is required.
• Program design is tricky.
• Programmer should be well skilled.
• Classes tend to be overly generalized.
Abstraction Encapsulation
• Abstraction is the process or method of gaining the • While encapsulation is the process or method to contain
information. the information.
• In abstraction, problems are solved at the design or • While in encapsulation, problems are solved at the
interface level. implementation level.
• Abstraction is the method of hiding the unwanted • Whereas encapsulation is a method to hide the data in a
information. single entity or unit along with a method to protect
information from outside.
• We can implement abstraction using abstract class • Whereas encapsulation can be implemented using by
and interfaces. access modifier i.e. private, protected and public.
• In abstraction, implementation complexities are • While in encapsulation, the data is hidden using methods
hidden using abstract classes and interfaces. of getters and setters.
• The objects that help to perform abstraction are • Whereas the objects that result in encapsulation need
encapsulated. not be abstracted.
• Abstraction provides access to specific part of data. • Encapsulation hides data and the user can not access
same directly (data hiding.
• Abstraction focus is on “what” should be done. • Encapsulation focus is on “How” it should be done.