Object Oriented Programming is a technique to create programs using classes (logical representation of data) and objects (physical representation of data). In this approach, object interacts with other objects by sending messages. It provides a great flexibility, modularity, reusability and security to an application.
Java is an object oriented and class based programming language. It implements all the features of object oriented programming like.
Class is a concept which encapsulates the members (variables and methods). It is a blue print of an object. Also you can say a class is a logical representation of data.
Object is an instance of a class. Object gets created dynamically in the heap memory of JVM. You can access the variables and methods through objects in the class. The object can be created using new keyword.
The variables, methods and the nested class are the member of the class.
Abstraction is the disclosure of necessary details of an object. So it can reduce the complexity and increase the efficiency. For example, the driver of a car doesn’t think about the individual internal parts of a car. He can think about only the behaviour of the car. This abstraction helps to driver to drive the car without any overhead of complexity of the parts that forms the car. He doesn’t know how the engine, gear system or breaking system is working.
It is a mechanism that binds the code and the data together. It protects the code and data from outside misuse. For Example, A house has some furniture like beds, tables, chairs etc. Those are protected by the house and only accessible by owner of the house. Outside people can’t access that furniture.
Polymorphism is an ability to define more than one method with same name. In java polymorphism comes in two flavor, method overloading or static polymorphism and method overriding or dynamic polymorphism.
Method overloading is a process of defining two or more methods with the same name.The signature of the methods must be varied with respect to no or type or order of parameters.
Method overriding is a process of defining two or more methods with the same name with same signature.
Inheritance is the process of creating a class based on another class. It gives us code reusability. For example, we extend a base class to a derived class. The derived class then inherits the properties of its base class.