The first difference is the syntax. Other than that, the major differences are:
C++
* OOP is optional.
* Compiled: produces non-portable native code.
* Manually managed memory. Garbage collection libraries are available.
* Source can be written to be portable, so a correctly written program can be compiled for any platform where a C++ compiler is available.
* Mostly used for medium-to-high performance applications, such as games.
Java
* Almost a purely OO language. It’s not purely OO because primitive types (e.g. int, float) can still be used.
* Semi-compiled: produces bytecode to be interpreted at run time by a virtual machine or a just-in-time compiler, depending on implementation.
* Memory is always managed by a garbage collector.
* Portability depends on availability of a Java implementation, but programs are usually compiled just once.
* Mostly used for web and embedded applications, where binary compatibility is more important than performance.
* C++ supports pointers whereas Java does not pointers. But when many programmers questioned how you can work without pointers, the promoters began saying “Restricted pointers.” So we can say java supports Restricted pointers.
* At compilation time Java Source code converts into byte code .The interpreter execute this byte code at run time and gives output .Java is interpreted for the most part and hence platform independent. C++ run and compile using compiler which converts source code into machine level languages so c++ is plate from dependents
* Java is platform independent language but c++ is depends upon operating system machine etc. C++ source can be platform independent (and can work on a lot more, especially embedeed, platforms), although the generated objects are generally platofrom dependent but there is clang forllvm which doesn’t have this restriction.
* Java uses compiler and interpreter both and in c++ their is only compiler
* C++ supports operator overloading and multiple inheritance but java does not.
* C++ supports Single and Multiple inheritance of classes, including virtual inheritance.. Java supports single inheritance of classes. Supports multiple inheritance via the Interfaces construct, which is equivalent to a C++ class composed of abstract methods.
* Java – no pointer and no pass-by-reference
* C++ supports Function pointers, function objects, lambdas (in C++11), and interfaces. In Java References to functions achieved via the reflection API. OOP idioms using Interfaces, such as Adapter, Observer, and Listener are generally preferred over direct references to methods.
* C++ is more nearer to hardware then Java
* Everything (except fundamental types) is an object in Java (Single root hierarchy as everything gets derived from java.lang.Object).
* Java does is a similar to C++ but not have all the complicated aspects of C++ (ex: Pointers, templates, unions, operator overloading, structures etc..) Java does not support conditional compile (#ifdef/#ifndef type).
* Thread support is built-in Java but not in C++. C++11, the most recent iteration of the C++ programming language does have Thread support though.
* Internet support is built-in Java but not in C++. However c++ has support for socket programming which can be used.
* Java does not support header file, include library files just like C++ .Java use import to include different Classes and methods.
* Java does not support default arguments like C++.
* There is no scope resolution operator :: in Java. It has . using which we can qualify classes with the namespace they came from.
* There is no goto statement in Java.
* Exception and Auto Garbage Collector handling in Java is different because there are no destructors into Java.
* Java has method overloading, but no operator overloading just like c++.
* The String class does use the + and += operators to concatenate strings and String expressions use automatic type conversion,
* Java is pass-by-value.
* Java does not support unsigned integer.