search
HomeJavaJavagetting StartedThree major characteristics of object-oriented: encapsulation, inheritance, polymorphism

Three major characteristics of object-oriented: encapsulation, inheritance, polymorphism

Jun 09, 2020 pm 05:30 PM
Polymorphismencapsulationinheritobject-oriented

Three major characteristics of object-oriented: encapsulation, inheritance, polymorphism

The three major characteristics of object-oriented: encapsulation, inheritance, and polymorphism.

Detailed introduction:

1. Encapsulation

Hide the properties and implementation details of the object, and only provide public access to the outside world.

Benefits: Isolate changes, facilitate use, improve reusability and security.

Principle: Hide content that does not need to be provided externally; hide attributes and provide public methods to access them.

(Recommended video tutorial: java video tutorial)

2. Inheritance

Improve code reusability. Inheritance is a prerequisite for polymorphism.

Note:

1. All constructors in the subclass will access the constructor with empty parameters in the parent class by default. By default, there is super() in the first line; if there is no empty parameter constructor Function needs to be specified in the subclass;

2. In the constructor of the subclass, you can use this to specify other constructors of your own.

3. Polymorphism

is a reference variable defined by a parent class or interface that can point to an instance object of a subclass or a specific implementation class.

Benefits: Improves the scalability of the program.

Disadvantages: When the parent class reference points to the subclass object, although the scalability is improved, only the methods in the parent class can be accessed, and the methods in the subclass cannot be accessed, which is the limitation of access.

Prerequisite: Implementation or inheritance relationship; override parent class method.

Recommended tutorial: java entry program

The above is the detailed content of Three major characteristics of object-oriented: encapsulation, inheritance, polymorphism. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:csdn. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.