OOP features in Java | Unit 1 | Class 11

0

Definition of OOPs

Object-oriented programming (OOP) is a programming language model organized
around objects rather than “actions” and data rather than logic. Historically, a program has been viewed as a logical procedure that takes input data, processes it, and produces output data.

Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Objects are made up of attributes and methods. Attributes are the characteristics that define an object; the values contained in attributes differentiate objects of the same class from one another.

Object

A Java object is a member (also called an instance) of a Java class. Each object has an identity, a behavior and a state. The state of an object is stored in fields (variables), while methods (functions) display the object’s behavior. Objects are created at runtime from templates, which are also known as classes.

There are three main features of OOPS.

1) Encapsulation
2) Inheritance
3) Polymorphism
4) Abstraction

Encapsulation

Encapsulation means putting together all the variables (instance variables) and the methods into a single unit called Class. It also means hiding data and methods within an Object. Encapsulation provides the security that keeps data and methods safe from inadvertent changes.

Inheritance

An important feature of object-oriented programs is inheritance—the ability to create classes that share the attributes and methods of existing classes, but with more specific features. Inheritance is mainly used for code reusability. So you are making use of already written the classes and further extending on that. That why we discussed the code reusability the concept. In general one line definition, we can tell that deriving a new class from existing class, it’s called as Inheritance.

Polymorphism

In Core, Java Polymorphism is one of easy concept to understand. Polymorphism definition is that Poly means many and morphism means forms. It describes the feature of languages that allows the same word or symbol to be interpreted correctly in different situations based on the context.

Abstraction

An Abstraction is a process of exposing all the necessary details and hiding the rest. In Java, Data Abstraction is defined as the process of reducing the object to its essence so that only the necessary characteristics are exposed to the users.
Abstraction defines an object in terms of its properties (attributes),behavior (methods), and interfaces (means of communicating with other objects).

Basic Features of OOP:

1. Emphasis on data rather than procedure.
2. Programs are divided into small parts called object.
3. Data and related functions stay tied in classes.
4. Data is secured as they can’t be accessed by external functions.
5. Objects may communicate with each other through functions.
6. New data and functions can be added easily whenever necessary.
7. Using inheritance, a class can be modified to create another one.
8. The complexity can be reduced.
9. Data Type can be created based on the necessity.

Leave a Reply

Your email address will not be published. Required fields are marked *