Comparison Index | C++ | Java |
Platform-independent | C++ is platform-dependent. | Java is platform-independent. |
Main application | System Programming. | Wide usage , mobile , desktop, web applications. |
Design Goal | C++ was designed for systems and applications programming. It was an extension of the C programming language. | Java was designed and created as an interpreter for printing systems but later extended as a support network computing. |
Multiple inheritance | Supports multiple inheritance. | Doesn't support multiple inheritance through class. It can be achieved by using interfaces in java. |
Operator Overloading | Supports operator overloading. | Doesn't support operator overloading. |
Pointers | C++ supports pointers. You can write a pointer program in C++. | Java supports pointer internally. However, you can't write the pointer program in java. It means java has restricted pointer support in java. |
Compiler and Interpreter | C++ uses compiler only. C++ is compiled and run using the compiler which converts source code into machine code so, C++ is platform dependent. | Java uses both compiler and interpreter. Java source code is converted into bytecode at compilation time. The interpreter executes this bytecode at runtime and produces output. Java is interpreted that is why it is platform-independent. |
Structure and Union | C++ supports structures and unions. | Java doesn't support structures and unions. |
Thread Support | C++ doesn't have built-in support for threads. It relies on third-party libraries for thread support. | Java has built-in thread support. |
Hardware | C++ is nearer to hardware. | Java is not so interactive with hardware. |
Virtual Keyword | C++ supports virtual keyword so that we can decide whether or not to override a function. | Java has no virtual keyword. We can override all non-static methods by default. In other words, non-static methods are virtual by default. |