Difference between Java and C
Categories: Core Java 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.
Basis | C | Java |
Language Level | C is a middle-level language. | Java is a high-level language. |
Paradigm | C is a structural and procedure-oriented programming language. | Java is an object-oriented programming language |
Approach | It follows the top-down approac h to design the application. | It follows the bottom-up approach to design the application. |
Translation | It is a compiled language. | It is an interpreted language. |
Platform Dependency | It is platform dependent. | It is platform-independent. |
Keywords | There are 32 keywords in C. | Java has 50 keywords. |
OOPs Concepts | It does not follow OOPs concepts. | It follows OOPs concepts. |
File Extension | The file is saved with the extension .c. | The file is saved with the extension .java. |
Building Block | Function driven. | Object and Class driven. |
Comment Style | / *comment*/ | //comment or /*comment*/ |
Security | It is not secure. | It is fully secured language. |
Translation Type | It translates the code into machine language so that the machine can understand the code. | It translates the code into a bytecode that is executed by the JVM. |
Pointers | It supports the concept of the pointer. | It does not support the concepts of pointers because of security. |
Exception Handling | Exception handling is not present in C language. | Exception handling is present in Java. |
Inheritance | It does not support inheritance that is useful for code reusability. | It supports inheritance that provides code reusability. |
Threading | There is no concept of threading. | It supports the concept of threading. |
Memory Management | It does not maintain memory, internally. | It maintains memory, internally. |
File Generation | It generates .exe file. | It generates .class file. |
Code Execution | It directly executes the code. | It executes code with the help of JVM. |
Call by value/ Call by reference | It supports both call by value and call by reference. | It supports only call by value. |
Portability | It is not portable. | It is portable. |
Goto Statement | It supports the goto statement. | It does not support the goto statement. |
Preprocessors Directives | Preprocessors are supported in C. | Preprocessors are not supported in Java. |
Robustness | It is not robust. | It is robust due to strong memory management. |
Used For | It is mainly used to develop system applications and firmware. | It is mainly used to develop enterprise applications and web-based applications. |
Polymorphism/ Virtual Function/ Operator Overloading | It does not support these features and concepts. | Java supports all these features and concepts. |
Popularity | It is less popular in comparison to Java. | It is the most popular programming language. |