Difference between C++ and Java2
|1.||It s compatible with c source code , except for a few corner cases.||No backward compatibility with any previous languages. But the syntax is highly influenced by c/c++.|
|2.||Write once, compile anywhere (WOCA).||Write one, run anywhere/everywhere (WORA/WORE).|
|3.||It allows procedural programming, functional programming, object-oriented programming and template meta-programming.||It strongly encourages an object-oriented programming paradigm.|
|4.||It allows direct calls to native systems libraries.||Call though the java Native interface and recently java Native Access.|
|5.||Exposes low-level system facilities.||Runs on a virtual machine. Does not always provide full access to the features and performance of the platform on which the software runs.|
|6.||It only provides object types and type names.||It is reflective, allowing meta-programming and dynamic code generation at runtime.|
|7.||Optional automated bounds checking.||Normally performs bound checking. HotSpot can remove bounds checking.|
|8.||It supports native unsigned arithmetic.||No native support for unsigned arithmetic.|
|9.||Pointers, references and pass-by-value are supported.||Primitive and reference data types always pass by value. No Pointer.|
|10.||Explicit memory management.||Automatic garbage collection, no concept of destructor and usage of finalize() is not recommended.|
|11.||It supports classes, structs and unions and can allocate them on heap or stack.||It support classes only and allocates them on heap.|
|12.||It allows explicit overriding types.||Rigid type safety except for widening conversions.|
Give the advantages of java over c++.
Advantages of java
Its benefits are as follows:-
- It is a simple programming language.
- It is object oriented programming language.
- In this, many computers can be run on one network.
- It is a very secure programming language.
- The feature of memory allocation and garbage collector is also available in this.
Advantages of C++
- Portability feature is available in C++ programming language. With the help of which the user can run the same program on any operating system.
- It is an object oriented programming language, this is its biggest feature. In object oriented programming language, we get features like classes, inheritance, polymorphism.
- It is a multi paradigm language. The term paradigm is used for the styling of the program.
- Memory management feature is also available in C++ programming language.