Difference Between Java and CPP (2)
Difference Between Java and CPP (2)
1. Platform Dependency
Java: Platform-independent. Java code is compiled into bytecode, which runs on the Java Virtual Machine
C++: Platform-dependent. C++ code is compiled directly into machine code for a specific OS and hardware.
2. Memory Management
Java: Uses automatic garbage collection. The JVM automatically handles memory cleanup.
3. Multiple Inheritance
Java: Does not support multiple inheritance with classes. Uses interfaces to achieve similar behavior.
C++: Supports multiple inheritance, allowing a class to inherit from multiple base classes.
4. Pointers
Java: Does not support direct use of pointers, enhancing safety and security.
C++: Fully supports pointers for direct memory access and manipulation.
Java: Code is compiled into bytecode and run by the JVM, making it portable but slightly slower.
C++: Code is compiled directly to native machine code, offering faster execution.