4 Characteristics of OOP

234 단어·2 분·원문(.md)

  • Encapsulation
    • A method of making the form of data and code unknown to the outside, and structuring the data's structure, role, and function into a single capsule.
  • Abstraction
    • Expressing common characteristics (variables, methods) of classes by grouping them together.
  • Inheritance
    • Using variables and methods defined in a parent class by inheriting them in a child class.
  • Polymorphism
    • Refers to a structure that can be expressed in various forms.

Encapsulation #

A method of making the form of data and code unknown to the outside, and structuring the data's structure, role, and function into a single capsule (information hiding).

  • Encapsulation Methods
    1. Attach the access modifier private before member variables. (private: accessible only within its own class)
    2. Create methods to set and retrieve values for member variables (getter, setter).

Abstraction #

Expressing common characteristics (variables, methods) of classes by grouping them together.

Inheritance #

Using variables and methods defined in a parent class by inheriting them in a child class.

e.g.) Using the extends keyword

Polymorphism #

The ability for an object to respond in its own unique way to a single message when performing an operation based on that message.

  • Methods Supporting Polymorphism
    • Overloading
    • Overriding

Overloading #

Defining multiple methods with the same name within a single class.

Overriding #

Changing and using the content of a method inherited from a parent class. Parameters and return type must be the same.

Back-End/JAVA/4특징.md