Difference between C++ and Java

The major differences between C++ and Java are listed in the following table.



Java
C++
1
Java programming language was invented by software developer James A. Gosling

C++ was invented by professor Bjarne   Stroustrup.

2
Java is Write once run anywhere or  everywhere (WORA  or WORE)
C++ is Write once compile anywhere (WOCA)
3
Java is completely or Strongly Object Oriented programming language.
C++ allows procedural programming, functional programming, object-oriented programming, and template meta programming.
4
Call through the Java Native Interface and recently Java Native Access
Allows direct calls to native system libraries.
5
No native support for unsigned arithmetic.
Supports native unsigned arithmetic.
6
Supports only class and allocates them on the heap.
Supports class, struct, and union and can allocate them on heap or stack.
7
No support for Operator overloading.
Support for operator overloading
8
No function pointer mechanism. Instead Interfaces, Adapters and Listeners are extensively used.
Support for function pointer mechanism.
9
Java supports multilevel inheritance and does not support multiple inheritance but instead java supports multiple interface inheritance.
Support for both multilevel and multiple inheritance
10
Java does not support destructors but rather adds a finalize() method.
C++ can use destructors.
11
Javadoc provides standard documentation.
C++ does not provide any kind of documentation.
12
final keyword is used to declare constant variables.
const keyword is used to declare constant variables.
13
Java offers automatic garbage collection.
Memory management in C++ is usually done through constructors, destructors, and smart pointers.
14
Java  allocates memory through object instantiation.
C++ can allocate arbitrary blocks of memory.
15
Java does not have global variables or functions because all the code in java program is encapsulated within the classes.
C++ have global variables or functions
16
Java is normally compiled to byte-code   which the Java virtual machine (JVM) then either interprets or JIT compiles to machine code and then executes.
C++ is normally compiled directly to machine code which is then executed directly by the operating system.
17
Java provides multi – threading capability.
Whereas C++ not possible.
18
Java does not support the goto statement However, it does support labeled break and continue statements.
C++ supports the goto statement.
19
The char type in Java is a 16-bit type and uses the Unicode character set (the Unicode values from 0 through 127 match the ASCII character set).
The char type in C++ is an 8-bit type that maps to the ASCII (or extended ASCII) character set.
20
There is no virtual keyword in Java.
Support for  virtual keyword in C++.
21
Java is platform independent language
C++ is depends upon operating system machine
22
Java use import to include different Classes and methods.
C++ support header file, include library files etc.
23
Java does not have preprocessing phase.
C++ compilation features an additional textual preprocessing phase.
24
"Java" is a trademark of Sun Microsystems (Oracle).

"C++" is not a trademark of any company or organization and is not owned by any individual.
25
The Java language is defined by the Java Language Specification.
The C++ language is defined by ISO/IEC 14882, an ISO standard  committee.