Understanding Java Basics: OOP, JVM, JDK, and Bytecode Explained
This article introduces core Java concepts, comparing procedural and object‑oriented thinking, explains what Java is, clarifies the relationships among JVM, JRE, and JDK, describes bytecode advantages, contrasts Java with C++, and details the three pillars of OOP—encapsulation, inheritance, and polymorphism—plus inner classes.
Java Basics Overview (01)
Compiled from various online sources, this section introduces fundamental Java knowledge.
Understanding Object‑Oriented Thinking
Procedural programming focuses on the executor, while object‑oriented programming (OOP) emphasizes the organizer. For example, generating a random number between 0‑10 procedurally requires designing an algorithm, whereas OOP uses the Random class to obtain the number directly.
OOP is about selecting appropriate tools and orchestrating them to accomplish a task, similar to a director assembling actors and crew to produce a film.
What Is Java?
Java is an object‑oriented programming language that incorporates many advantages of C++ while eliminating complex features such as multiple inheritance and pointers. It offers powerful functionality with simplicity, enabling developers to write elegant, complex programs.
JVM, JRE, and JDK Relationship
JVM – The Java Virtual Machine executes Java programs on any platform, providing Java’s cross‑platform capability.
JRE – The Java Runtime Environment includes the JVM and core class libraries (e.g., java.lang) required to run Java applications. Installing the JRE alone is sufficient to execute compiled Java programs.
JDK – The Java Development Kit supplies development tools (compiler javac, packager jar, etc.) and bundles a JRE. Installing the JDK eliminates the need for a separate JRE installation.
What Is Bytecode? Benefits of Bytecode
Bytecode is the .class file produced after the Java source code is compiled by the virtual machine compiler. It targets the JVM rather than any specific processor.
Benefits include improved execution efficiency compared to pure interpreted languages while retaining portability; the same bytecode can run on any machine with a compatible JVM without recompilation.
Java vs. C++
Both are object‑oriented languages supporting encapsulation, inheritance, and polymorphism.
Java lacks direct pointer manipulation, offering safer memory handling.
Java classes support single inheritance; C++ allows multiple inheritance (Java achieves multiple inheritance via interfaces).
Java provides automatic memory management, eliminating manual deallocation.
Three Core OOP Features
Abstraction : Summarizes common characteristics of a group of objects into a class, focusing on what attributes and behaviors an object has, not how they are implemented.
Encapsulation : Hides an object's internal state by making fields private and exposing controlled access through methods.
Inheritance : Enables a new class to reuse and extend the definition of an existing class, promoting code reuse and forming the basis for polymorphism.
Polymorphism : Allows a reference variable to refer to objects of different subclasses, with the actual method implementation determined at runtime. Implemented via method overriding (runtime) and method overloading (compile‑time).
Object Equality: == vs. equals()
==compares object references (whether two references point to the same memory address). For primitive types, it compares values. equals() can be overridden to compare object content. If not overridden, it behaves like ==; when overridden, it returns true when the objects' internal data are considered equal.
Inner Classes
An inner class is defined within the scope of another class. Java defines four types of inner classes: member inner class, local inner class, anonymous inner class, and static inner class.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Intelligent Backend & Architecture
We share personal insights on intelligent, automated backend technologies, along with practical AI knowledge, algorithms, and architecture design, grounded in real business scenarios.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
