Java Object Oriented Programming (OOPs) Concepts.

As the name suggests, the Object-Oriented Programming or OOPs refers to the language that uses the concept of class and objects in programming. The aim of object-oriented programming is to implement real-world entities such as inheritance, abstraction, polymorphism, and encapsulation. Most of the programming languages like java, python, C#, C++, PHP, etc. uses the object-oriented programming paradigm. The Simula is considered as the first object-oriented programming language.


Java OOPs Concepts


Java OOPs Concepts:


Here, we will learn the basic Java OOPs Concepts that help you to implement the object-oriented model. These are class, object, inheritance, polymorphism, etc. Let's take a look at these concepts now:



The most important thing to understand about a class is that it is used to defines a new data type. Once we defined, this new data type can be used to create objects of that type. Thus, we can say that a class is a template for an object, and an object is an instance of a class. A class in Java contains methods, fields, constructors, blocks, and interfaces.


2. Object:

The Object is an entity that has state and behavior. The object is an instance of a class and an object is a real-world entity. To access the members which are defined in the class you need to create an object.
for example: a chair, pen, table, bike, book, etc are the example of Object.


Data abstraction is defined as the process of hiding the internal details from the user and showing only functionality. Consider a real-world example of a man driving a car. When a man driving a car he pressing the accelerators to increase the car speed and applying the brake to stop the car but he doesn't know how pressing the accelerators will increase the car speed and applying the brake will stop the car. The man doesn't know the inner mechanism of a car. This is called abstraction. Data abstraction can be achieved through Abstract Class.



4. Encapsulation:

Encapsulation is an act of combining properties and methods of the same entity. In other words, it is a process of wrapping the data (variables) and code together in a single unit. It is an OOPs concept. Encapsulation is also known as data hiding because the data in a class is hidden from other classes. Every java class is an example of encapsulation.


5. Polymorphism:

Polymorphism in Java is a concept which allows you to perform a single action in different ways. It is the ability of an object or method to take different forms as per requirements. Polymorphism is one of the most important features of object-oriented programming (OOPs). Polymorphism is a combination of 2 Greek words: poly and morph. The poly word means many and morphs words means forms. So when one thing has many forms it is known as polymorphism. We can achieve polymorphism in java through method overloading and method overriding.


6. Inheritance: 

Inheritance is one of the key features of object-oriented programming (OOPs). Inheritance is a process of inheriting the properties and behavior of the existing class into a new class. When we inherit the class from an existing class, we can reuse the methods and fields of the parent class. Inheritance can be defined as an Is-A relationship, which is also known as the parent-child relationship. The main purpose of inheritance is code reusability.




You may also like these related posts:

Java Object Oriented Programming (OOPs) Concepts. Java Object Oriented Programming (OOPs) Concepts. Reviewed by Prashant Srivastava on December 21, 2019 Rating: 5

No comments:

Powered by Blogger.