There are many differences and similarities between the C++ programming language and the Java programming language. The list of top differences between them are given below:

Comparison IndexC++                                                     Java                                                            
Platform IndependentC++ is platform dependent.Java is platform-independent.
Mainly used forIt is mainly used for system programming.It is mainly used for application programming.
It is widely used in windows, web-based,
enterprise and mobile applications.
GotoC++ supports the goto statement.Java doesn't support the goto statement.
Multiple InheritanceC++ supports multiple inheritance.Java doesn't support multiple inheritance
through class. It can be achieved by interfaces
in java.
Operator OverloadingC++ supports operator overloading.Java doesn't support operator overloading.
Call by Value and
Call by reference
C++ supports both call by value and call
by reference.
Java supports call by value only. There is no
call by reference in java.
Inheritance TreeC++ creates a new inheritance tree
Java uses a single inheritance tree always
because all classes are the child of the Object
class in java. The object class is the root of
the inheritance tree in java.


  • Java doesn't support default arguments like C++.
  • Java doesn't support header files like C++. Java uses the import keyword to include different classes and methods.

C++ Example

File: main.cpp

#include <iostream>  
using namespace std;  
int main() {  
   cout << "Hello C++ Programming";  
   return 0;  

Java Example


class Simple{  
    public static void main(String args[]){  
     System.out.println("Hello Java");