Difference between Java and C/C++
Difference between Java and C
- Java is a platform independent language. But c is not a platform independent is depends on operating system machine.
- Java uses both compiler and interpreted, but c is uses compiler only.
- Java is object oriented programming language but c language is procedural as well as structured programming language.
- In c memory management is manually using malloc( ) and free( ), but java provides a garbage collector to manage memory.
- Goto statement is used in c but it not used in java.
- In c variable declared in a program beginning of the block and java variable declared anywhere in the program .
- Java does not support pointer but c support pointer.
- C language is used preprocessor (e.g # define) but java not support prepocessor.
- Java does not support operator overloading but c support operator overloading.
- java does not support global variable but c is support global variable.
- String is an array of Characters into C .But in case of Java String type is as Object.
Difference between Java and C++
- Java is a platform independent language language. But c++ is not a platform independent language it depend on operating system machine.
- Java does not support multiple inheritance but, c++ support multiple inheritance.
- java does not support pointer, union, structure, templates, operator overloading but, c++ is support pointer, union, structure, templates, operator overloading and pointer arithmetic.
- java uses compiler and interpreter both but, c++ is use compiler only.
- At compilation time java program first java source code is compile then generate byte code means (.class ) and after interpreted convert the machine code before execution. But c++ run and compile uses compiler which convert source code into machine language.
- Java has support method overloading but not support operator overloading. C++ support both method overloading and operator overloading.
- Java has primitive data type like boolean which are not available in c++.
- java has support documentation comment( /**............*/ ) , but c++ is not support documentation comment.
- Java does not support scope resolution operator (: :), But c++ is support resolution operator.
- Java does not support goto (but goto is reversed word).
- C++ is more nearer to hardware then java.
- Java does not support unsigned integer.
- Java does not support global variable.
- Thread support built in java but not c++.
- Java does not support header file just like c++. it use import to add the class and interrface.
- Exception and Auto Garbage Collector handling in Java is different because there are no destructors into Java.