java和c++的不同点
BASIS FOR COMPARISON | C++ | Java |
---|---|---|
Memory Management | Managed by developers using pointers. Supports structures and union | Controlled by the system, does not use pointers. Supports Threads and Interfaces |
Inheritance | Provide single and multiple inheritances both | Does not support multiple inheritances. Uses the concept of Interface to achieve |
Runtime error detection mechanism | Programmer’s responsibility | System’s responsibility |
Libraries | Comparatively available with low-level functionalities | Provide a wide range of classes for various high-level services |
Program Handling | Methods and data can reside outside classes. The concept of a global file, namespace scopes available | All methods and data reside in the class itself. Concept od Package is used. |
Type Semantics | Supports consistent support between primitive and object types | Different from primitive and object types |
Portability | Platform dependent as source code must be recompiled for different platform. | It uses the concept of bytecode which is platform-independent and can be used with platform-specific JVM. |
Polymorphism | Explicit for methods supports mixed hierarchies | Automatic uses static and dynamic binding |