Written by - Yash Agrawal

Cpp vs Java


Comparison IndexC++Java
Platform-independentC++ is platform-dependent.Java is platform-independent.
Main applicationSystem Programming.Wide usage , mobile , desktop, web applications.
Design GoalC++ 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 inheritanceSupports multiple inheritance.Doesn't support multiple inheritance through class. It can be achieved by using interfaces in java.
Operator OverloadingSupports operator overloading.Doesn't support operator overloading.
PointersC++ 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 InterpreterC++ 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 UnionC++ supports structures and unions.Java doesn't support structures and unions.
Thread SupportC++ doesn't have built-in support for threads. It relies on third-party libraries for thread support.Java has built-in thread support.
HardwareC++ is nearer to hardware.Java is not so interactive with hardware.
Virtual KeywordC++ 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.