OOPS contains 8 principles. They are:
- Data Abstraction
- Data Encapsulation
- Dynamic Binding
- Message Passing
Class is a way of binding the Data Members and Methods in a single unit.
- Syntax to define a User-defined Data type: Class
Variable / Data member declaration
e.g.: class Student
Real world entities are called objects.
- Object creation:
<ClassName> objName = new <ClassName()>;
e.g.: Student s = new Student ();
3. Data Abstraction:
It is a mechanism of retrieving the required/essential information by hiding background details.
4. Data encapsulation:
Data Encapsulation is a process of wrapping up of data in a single unit.
It’s a process of acquiring the features (data members and member methods) of one class into another class.
TYPES OF INHERITANCE:
a) Single Inheritance: In this, There is exist one base class and one derived class.
b) Multilevel Inheritance: In this, there exists one Base Class, one derived class and n # Intermediate Base Classes.
c) Multiple Inheritance: In this, there exists n # base classes and one derived class. Java doesn’t support multiple Inheritances to the classes directly but it supports indirectly through the Interface.
d) Hierarchical Inheritance: In this, there exists one base class and n # derived class.
e) Hybrid Inheritance: It is a combination of two valid Inheritances.
It is a mechanism to represent one form in many forms.
- We can have two types of Polymorphism:
- Static or Compile Time Polymorphism.
- Dynamic or Run Time Polymorphism.
7. Dynamic binding:
Dynamic Binding is a way of binding the appropriate versions of derived classes which are inherited from same base class with Base class object.
8. Message Passing:
Message passing is a process of exchanging the data between multiple objects either locally or globally.