Skip to content

OOP Principles #42

@sophryu99

Description

@sophryu99

Object Oriented Programming, OOP

The purpose of OOP:

  • To create understandable, readable, and testable code that many developers can collaboratively work on

Properties of OOP:

1. Abstraction:

  • aims to hide complexity from users and show them only relevant information
  • For an example, when you are driving a car, you don't need to know about the engines and the internal workings.

2. Encapsulation:

  • Helps with data security; allows you to protect the data stored in a class from system-wide access

3. Inheritance:

  • Makes it possible to create a child class that inherits the fields and methods of the parent class
  • The child class can override the values and methods of the parent class; it can also add new data and functionality to its parent
  • Parent class = superclass, base class
  • Child class = subclass, derived class

4. Polymorphism:

  • Refers to the ability to perform a certain action in different ways
  • In Java, there are two forms: method overloading and method overriding
  • Method overloading: happens when various methods with the same name are present in a class. They are differentiated by the number, order, or types of their parameters
  • Method overriding: occurs when a child class overrides a method of its parent

Source

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions