search
HomeJavajavaTutorialjava what is object oriented

java what is object oriented

May 20, 2019 pm 01:53 PM
javaobject-oriented

Java object-oriented refers to simulating concepts in the real world in computer programs, and using similar entities in computer programs to simulate entities in the real world with the help of object descriptions.

java what is object oriented

#What are objects and object-oriented programming?

Objects are specific entities that exist, with clearly defined states and behaviors. They are the core of object-oriented programming. They are used to describe entities in the real world, provide an entity basis for computer applications, and are also a way to complete specific tasks. Encapsulation. It's a bit long-winded to describe the object like this. Because it is different from the traditional C language, C language is a procedural language, and Java language is an object-oriented language, so objects are the core of Java language.

So what exactly is an object? Can you give an example? In fact, in our lives, everything can be abstracted into an object. For example, if you have a car, this car is the object. This object (car) has a color, a brand, a place of origin, etc. We can also call these things Its properties, it can also operate, need to be repaired, etc., we become its behavior. This is the object.

In object-oriented programming (abbreviation: OOP), all things in the real world are regarded as objects. The goal of OOP is to simulate concepts in the real world in computer programs. We can use similar entities to simulate entities in the real world in computer programs with the help of object descriptions. At the same time, OOP is also a method for designing and implementing software systems.

Object-oriented thinking

Because object-oriented thinking can be simply summarized into three: Encapsulation, Inheritance and Polymorphism.

Encapsulation: It is to seal certain content so that others cannot know it. Some objects have internal implementation details of their own attributes that we don't want other objects to know, so we can encapsulate them. This is the basic concept of encapsulation.

Inheritance: As the name suggests, inheritance is the inheritance of a son from his father. A class can also have subclasses and parent classes. The subclass inherits from the parent class, but inheritance is not all inherited if the subclass and the parent class are in the same package. The subclass inherits all non-private member methods (except constructors) and non-private member variables in the parent class. We will introduce the details of inheritance later. The goal of inheritance is to reuse code and save development time.

Polymorphism: The same operation acts on different objects and can have different interpretations and produce different execution results. At runtime, methods in the implemented subclass can be called through a pointer to the parent class. Polymorphism in Java is generally divided into method rewriting and method overloading.

Compile-time polymorphism: Compile-time polymorphism is achieved through overloading. For non-virtual members, the system determines what operation to implement based on the parameters passed, the type returned, and other information during compilation.

Runtime polymorphism: Runtime polymorphism means that it is not until the system is running that the operation is decided based on the actual situation. Compile-time polymorphism provides us with fast running speed, while run-time polymorphism brings high flexibility and abstraction.

Related learning recommendations: java basics

The above is the detailed content of java what is object oriented. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
JVM performance vs other languagesJVM performance vs other languagesMay 14, 2025 am 12:16 AM

JVM'sperformanceiscompetitivewithotherruntimes,offeringabalanceofspeed,safety,andproductivity.1)JVMusesJITcompilationfordynamicoptimizations.2)C offersnativeperformancebutlacksJVM'ssafetyfeatures.3)Pythonisslowerbuteasiertouse.4)JavaScript'sJITisles

Java Platform Independence: Examples of useJava Platform Independence: Examples of useMay 14, 2025 am 12:14 AM

JavaachievesplatformindependencethroughtheJavaVirtualMachine(JVM),allowingcodetorunonanyplatformwithaJVM.1)Codeiscompiledintobytecode,notmachine-specificcode.2)BytecodeisinterpretedbytheJVM,enablingcross-platformexecution.3)Developersshouldtestacross

JVM Architecture: A Deep Dive into the Java Virtual MachineJVM Architecture: A Deep Dive into the Java Virtual MachineMay 14, 2025 am 12:12 AM

TheJVMisanabstractcomputingmachinecrucialforrunningJavaprogramsduetoitsplatform-independentarchitecture.Itincludes:1)ClassLoaderforloadingclasses,2)RuntimeDataAreafordatastorage,3)ExecutionEnginewithInterpreter,JITCompiler,andGarbageCollectorforbytec

JVM: Is JVM related to the OS?JVM: Is JVM related to the OS?May 14, 2025 am 12:11 AM

JVMhasacloserelationshipwiththeOSasittranslatesJavabytecodeintomachine-specificinstructions,managesmemory,andhandlesgarbagecollection.ThisrelationshipallowsJavatorunonvariousOSenvironments,butitalsopresentschallengeslikedifferentJVMbehaviorsandOS-spe

Java: Write Once, Run Anywhere (WORA) - A Deep Dive into Platform IndependenceJava: Write Once, Run Anywhere (WORA) - A Deep Dive into Platform IndependenceMay 14, 2025 am 12:05 AM

Java implementation "write once, run everywhere" is compiled into bytecode and run on a Java virtual machine (JVM). 1) Write Java code and compile it into bytecode. 2) Bytecode runs on any platform with JVM installed. 3) Use Java native interface (JNI) to handle platform-specific functions. Despite challenges such as JVM consistency and the use of platform-specific libraries, WORA greatly improves development efficiency and deployment flexibility.

Java Platform Independence: Compatibility with different OSJava Platform Independence: Compatibility with different OSMay 13, 2025 am 12:11 AM

JavaachievesplatformindependencethroughtheJavaVirtualMachine(JVM),allowingcodetorunondifferentoperatingsystemswithoutmodification.TheJVMcompilesJavacodeintoplatform-independentbytecode,whichittheninterpretsandexecutesonthespecificOS,abstractingawayOS

What features make java still powerfulWhat features make java still powerfulMay 13, 2025 am 12:05 AM

Javaispowerfulduetoitsplatformindependence,object-orientednature,richstandardlibrary,performancecapabilities,andstrongsecurityfeatures.1)PlatformindependenceallowsapplicationstorunonanydevicesupportingJava.2)Object-orientedprogrammingpromotesmodulara

Top Java Features: A Comprehensive Guide for DevelopersTop Java Features: A Comprehensive Guide for DevelopersMay 13, 2025 am 12:04 AM

The top Java functions include: 1) object-oriented programming, supporting polymorphism, improving code flexibility and maintainability; 2) exception handling mechanism, improving code robustness through try-catch-finally blocks; 3) garbage collection, simplifying memory management; 4) generics, enhancing type safety; 5) ambda expressions and functional programming to make the code more concise and expressive; 6) rich standard libraries, providing optimized data structures and algorithms.

See all articles

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

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version

EditPlus Chinese cracked version

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

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools