Posted By:
8 Feb, 2014 4:31 am PST

Difference Between Java And C++

Difference between Java and C++ programming language


 1.Java is a hybrid language.  
  1. ++ is almostpurely object oriented language but not hybrid in nature.In Java every thing is related to class & object concept but there are a few primitive types (int,double,etc) that are not class types.
  1.  eliminates the concept of preprocessor.

2.C++ provide a preprocessor. Some preprocessor directives:#include, #define, etc

  1.  The developers of Java felt that many C/C++ features were overly complex, tricky, and led to code that was unreliable and difficult to debug.
  1. .C++ provides a wide variety of features.All those of C,plus many new ones.
 4. Java doesn’t have pointersAn alternate feature ,object references, provides some of the same capabilities  

.4. C++ programs rely heavily on pointers.

  1. Java ,dynamic memory is freed automatically, by the system.A “garbagecollection” process runs in the background, looking for memory that is in accessible.Inaccessible memory is freed,when it is found.

5. In C++, dynamic memory is freed with the delete operator. Typically this is done in a destructor, sometimes without system(OS) permission freeing the memory can lead error


Only„+ â��operator is in built overloaded to concatenate the two objects of String Class

 6. C++ allows most operators to be overloaded.
 7. Java provides single inheritance.A subclass may have only ones uperclass.Java also supports a very restricted form of multiple inheritance,via a feature called an “interface”.  
  1.  C++ provides unrestricted multiple inheritance.A subclass (derived class,in C++ terminology) may have any number of superclasses(baseclasses).

 8. Typically, Java isinterpreted

 8. Normally, C++ is fully compiled..
 9. Java has the role of virtual environment(through JVM),that’s why it is fully architectur eneutral
  1. It can be OS independent(in some cases) but its not Hardware/Machine independent.


10. Java supports only classes. 10. C++ supports classes,structuresor unions. 

11. scope resolution operator(::).

11 Uses scope resolution operator(::). 

12. goto statement

12. C++ supports goto statement. 

13 In Java class definition is very similar as C++,but presence of semicolon is not required.

13.In C++ class definition,class is closed by semicolon after the curly brace.


14. Injavathedataisnotglobalitsal waysencapsulatewithin the class,so outsiders arenotabletoaccesssuchdata. Inthiswaythejavaismoresecure.

14. So,in C++ the data can be available at global place means outside the class,so outsiders can easily access such data.In this way the C++ is less secure than Java.


Pros of Java over C++

1.Easier to read ,understand and code in Java than C++.

2.We have less error prone environment in Java than C++.

3.Garbage collector that removes and cleans up the dead object, so user don’t have to have the burden of keeping track of these objects.There is no garbage collector in C++.

4.Various free IDEs available on all platforms, such as Eclipse. It's safe and easy to make application using IDEs.No such IDEs are there for C++.

5.Easier/more cross-platform networking than C++.

6.Easy to make multiple threads, and you can declare functions synchronized so only one thread can be in them at a time

7.NopointersandPreprocessorsrequired.And Java is a secure language too.


Consof Java over C++

1.Java usesmorememorythan C++.

2.Java has no unsigned Integer.

3.Some things are renamed in Java. Example:const is final in Java

4. Java is quite slow, because it is compiled at run-time by the system's virtual machine

5. It is difficult to compile into a stand-alone application.



Please login to reply to this problem.