Object-Oriented programming (OOPS)
Object-oriented programming (OOPs) is a programming paradigm in which we write code with the perception of the real world by using real-world entities (objects) while writing the programs. thus, Uses a Bottom-up approach.
Example: C++, C#, Java, PHP, Python, etc
Advantages
- It provides a user-friendly application by hiding the implementation details,
- Objects can even be reused inside and across applications. The application of software systems additionally lowers the price of development.
- It also makes the software system easier to keep up with. As for updating, making changes in source code is easier.
- Reuse additionally allows quicker development. OOPs languages go along with made libraries of objects, and code develops throughout comes is additionally reusable in future comes.
- however, OOPs allows the programmer to take new and existing software objects and combine them together to make new programs.
Objects & Classes | OOPS
The object is a real-world entity, which has an identity, state, and behavior.
Class is a group of objects which thus contains similar properties, relationships, behavior with other objects, and common semantics. It is a blueprint from which an object is created.
In C++
In java
Inheritance
Inheritance is the process that also allows a child class to inherit the features of the parent class. The main aim is to gain reusability.
in C++
In Java
The main difference between c++ and java is that java doesn’t support multiple inheritances.
Polymorphism
Polymorphism is a Latin word poly means many and morphism means form. therefore, it is a method to possess different behavior in different situations.
Compile Time polymorphism
Runtime polymorphism
in C++
o/p DERIVED
c++ also requires a virtual keyword for runtime polymorphism.
Java
o/p DERIVED
Java does not support operator overloading.
however, Java does not require a virtual keyword for runtime polymorphism.
In java, all the non-static methods are also overridden by defaults.
Encapsulation
Encapsulation is therefore the process for enclosing one or more information from the outside world through access right. It is wrapping data and code together.
Abstraction
Abstraction is the process in which only essential details are shown to the user and also hiding implementation detail from the user to make the application user friendly.
We can achieve abstraction by abstract class and interface.
Java
In java, we have keywords like abstract and interface.
Code
Abstract
Interface
Using interfaces in java we can also apply multiple inheritances.
In C++
In c++ we don’t have keywords like abstract and interface but here with the help of virtual we are going to implement it.
Code
Conclusion | OOPS
C++ and Java both support object-oriented programming but as java was developed after c++ so to make java memory safe and free from ambiguities we add and remove some functionalities. however, Java removes functionality like operator overloading, multiple inheritances, virtual, etc and we add keywords like interface and abstract to improve the implementation abstraction. so, Java has a large set of libraries.
written by: Charchil Gupta
Reviewed by: Soutik Maity
If you are Interested In Machine Learning You Can Check Machine Learning Internship Program
Also Check Other Technical And Non Technical Internship Programs