OOPS CONCEPTS IN JAVA
In java oops is also called as Object Oriented Programming Language.
OBJECT ORIENTED CONCEPTS:
Java is an Object-Oriented Language that supports the following fundamental concepts are;
- Polymorphism
- Inheritance
- Encapsulation
- Abstraction
- Class
- Object
- Instance
- Method
- Message passing
1. Polymorphism:
If one task is performed in different ways, it is known as polymorphism.
It is the feature of "one name many forms" method performs different tasks.
Types of polymorphism:-
* Compile time polymorphism.
* Run-time polymorphism.
2. Inheritance:
It is the process of creating a new class from existing class.
Base class is parent class and child class is sub class.
When one of the object acquires all the properties and behaviors of a parent object, it is known as inheritance.
3. Encapsulation:
Binding (or wrapping) code and data together into a single unit are known as encapsulation.
4. Abstraction:
Hiding internal details and showing the functionality is known as abstraction.
5. Class:
It is a container for data and functions.
6. Objects:
It is instance of a class.
Object can create multiple objects with same behavior, instead of repeating code.
Any entity that has state and behavior is known as an object.
For example, a chair, pen, table, keyboard, bike, etc.
7. Instance:
An Object can be defined as an instance of a class. An object contains an address and takes up some space in memory.
8. Method:
Method is a collection of statements that perform some specific task and return the result to the caller.
9. Message Passing:
Message Passing is nothing but sending and receiving of information by the objects.
Sending messages from one thread to another.