Question: What are the characteristics of object orientation?

A: Encapsulation, inheritance, polymorphism and abstraction.

Encapsulation provides an object with the ability to hide its internal features and behavior. The object provides methods that can be accessed by other objects to alter its internal data. In Java, there are three modifiers :public, private, and protected. Each of these modifiers gives different access to other objects in the same package or under different packages.

Some of the benefits of using encapsulation are listed below:

  • Protect the internal state of an object by hiding its properties
  • Improved code availability and maintainability because the behavior of objects can be individually changed or extended
  • Improve modularity by prohibiting undesirable interactions between objects

Inheritance gives objects the ability to get fields and methods from their base classes. Inheritance provides lines of code for reuse and the ability to add new features to existing classes without modifying them.

3. Polymorphism Polymorphism is the ability of programming languages to present the same interface to different underlying data types. Operations on one polymorphic type can be applied to values of other types.

Abstraction is the step of separating ideas from concrete instances, so create classes based on their functionality rather than implementation details. Java supports the creation of abstract classes that expose only interfaces and do not contain method implementations. The main purpose of this abstraction technique is to separate the behavior of a class from implementation details.