Skip to content
Java introduction 3 min read

Features of Java

Java’s enduring popularity is no accident. A handful of deliberate design features — chosen in the 1990s and refined ever since — make it productive, portable, and dependable at scale. This page covers the features every Java developer should be able to articulate.

Platform Independence

Java source code compiles to bytecode (.class files), not native machine code. That bytecode runs on any Java Virtual Machine (JVM), regardless of the underlying operating system or CPU. This is the famous “Write Once, Run Anywhere” (WORA) promise.

// Compiled once into bytecode, this runs on Windows, macOS, and Linux unchanged.
public class Portable {
    public static void main(String[] args) {
        System.out.println("Same bytecode, any platform!");
    }
}

Output:

Same bytecode, any platform!

Object-Oriented

Java is fundamentally object-oriented, organizing software around objects that bundle state and behavior. It supports the four pillars cleanly:

  • Encapsulation — hide internal state behind methods and access modifiers.
  • Inheritance — share and extend behavior via extends.
  • Polymorphism — one interface, many implementations.
  • Abstraction — expose what an object does, not how.
abstract class Shape {
    abstract double area();
}

class Circle extends Shape {
    private final double radius;          // encapsulation
    Circle(double radius) { this.radius = radius; }
    @Override double area() {             // polymorphism
        return Math.PI * radius * radius;
    }
}

Note: Java is almost purely object-oriented. Primitive types (int, double, boolean, etc.) exist for performance and are not objects — though autoboxing bridges them to their wrapper classes seamlessly.

Simple and Familiar

Java borrowed C and C++ syntax to ease adoption but removed their most error-prone features: explicit pointers, manual memory freeing, multiple inheritance of classes, and operator overloading. The result is a language that is approachable yet powerful.

Automatic Memory Management

Java uses a garbage collector to reclaim memory occupied by objects no longer referenced. Developers allocate with new but never manually free memory, eliminating entire classes of bugs like dangling pointers and most memory leaks.

String greeting = new String("hello"); // allocated
greeting = null;                        // now eligible for garbage collection

Robust and Secure

Java emphasizes early error detection and safe execution:

  • Strong static typing catches many mistakes at compile time.
  • Exception handling forces programs to deal with error conditions explicitly.
  • Array bounds checking and the absence of pointer arithmetic prevent buffer overflows.
  • The JVM verifies bytecode before execution and runs untrusted code in a controlled environment.

Multithreaded and Concurrent

Java has had built-in concurrency support since version 1.0, with threads, synchronization, and a rich java.util.concurrent toolkit. Modern Java (21+) adds virtual threads, making millions of lightweight concurrent tasks practical.

Thread.ofVirtual().start(() ->
    System.out.println("Running on a virtual thread"));

High Performance

While bytecode is interpreted initially, the JVM’s Just-In-Time (JIT) compiler translates hot code paths into optimized native machine code at runtime. Mature JVMs like HotJava deliver performance rivaling natively compiled languages for long-running workloads.

Feature Summary

FeatureBenefit
Platform independentOne artifact runs everywhere
Object-orientedMaintainable, modular design
Garbage collectedNo manual memory management
Strongly typedErrors caught at compile time
MultithreadedFirst-class concurrency
JIT compiledNear-native runtime speed
SecureBytecode verification & sandboxing

Best Practices

  • Favor immutability (final fields, immutable objects) to make concurrent code safer.
  • Let the garbage collector work — avoid premature optimization of memory; profile first.
  • Lean on the type system and generics to catch errors before runtime.
  • Prefer the high-level java.util.concurrent utilities over hand-rolled thread management.

Interview Questions

Is Java fully object-oriented? No. Java is object-oriented but retains primitive types for performance, so it is not considered a “pure” object-oriented language.

How does Java achieve platform independence? The compiler produces bytecode rather than native code. Any platform with a compatible JVM can execute that bytecode, enabling “Write Once, Run Anywhere.”

What handles memory cleanup in Java? The garbage collector automatically reclaims memory from unreachable objects, so developers never explicitly free memory.

Last updated June 1, 2026
Was this helpful?