There are many differences and similarities between C and Java language. Some differences between C and Java are mentioned below:
S.No | C Language | Java |
---|---|---|
C does not support object-oriented programs concepts. It is a procedural oriented programming language. | Java support object–oriented programming language concepts. | |
C uses structure, union and enum data types. | Java does not support data types like structure, union and enum. | |
C uses type modifiers keywords like auto, extern, register, signed and unsigned. | Java does not support type modifiers keywords like auto, extern, register, signed and unsigned. | |
C uses preprocessors #define, #include and #ifdef. | Java does not have a preprocessors like #define, #include and #ifdef. | |
C uses malloc function to allocate memory at run time. | Java use new operator to allocate memory at run time. | |
C supports both call-by-value and call-by-reference. | Java supports call-by-value only, no call-by-reference concepts. | |
In C, we can declare variables outside a main() function for global declaration. | In Java, variables and methods is declared within a class only. Declaration not possible output main() method. | |
In C, Pointers can be used. | There is no concept of pointers in Java. | |
C supports goto statement. | Java doesn't support goto statement. | |
In C, we include a header file before using function. | In Java, there is no concept of header files, only packages are used. |
There are many differences and similarities between C++ and Java language. Some differences between C++ and Java are mentioned below:
S.No | C++ Language | Java |
---|---|---|
C++ is platform dependent. | Java is platform Independent. | |
C++ uses compiler only. | Java uses compiler and interpreter both for converting source code into machine code. | |
C++ is both a procedural and an object-oriented programming language. | Java is only an object-oriented programming language. | |
C++ supports both method overloading & operator overloading concept. | Java supports only method overloading, operator overloading is not allowed. | |
C++ uses template classes. | Java does not have template classes. | |
C++ support multiple inheritance. | Java doesn't support multiple inheritance through class. It can be achieved by interfaces in Java. | |
C++ uses destructor to destroy allocated memory. | Java has replaced destructor with finalize() method. | |
C++ uses virtual function and virtual classes. | In Java, there is no concept of virtual keyword. | |
Multi-threading programming cannot be possible in C++. | Java supports multi-threading programming. | |
C++ is mainly used for system programming. | Java is mainly used for application programming. It is widely used in window, web-based, enterprise and mobile applications. |