Both Java and C++ use same syntax and are Object Oriented, but there are several differences between Java and C++:
1. Java does not use pointers. Pointers are inherently tricky to troublesome and use.
2. Java does not support multiple inheritances because it creates more problems than it solves. Instead Java supports multiple interface inheritance, which gives an object to inherit many method signatures from different interfaces with the condition that the inheriting object must implement those inherited methods. The multiple interface inheritance also gives an object to behave polymorphically on these methods.
3. Java does not support destructors but adds a finalize() function or method. Finalize methods are invoked by the garbage collector prior to reclaiming the memory accessed by the object, which has the finalize() method. That means you do not know when the objects are going to be finalized. Avoid using finalize() method to release nonmemory resources like file handles, database, sockets connections etc because Java has only a fix number of these resources and you do not know when the garbage collection is going to kick in to release these resources through the finalize() method.
4. Java does not include unions or structures because the traditional data structures are implemented as an object oriented framework.
5. All the code in Java program is encapsulated within classes therefore Java does not have functions or global variables.
6. C++ needs explicit memory management, while Java have automatic garbage collection.