Difference between Java and C

Difference between Java and C

Previous Home Next


Java is an pure object oriented programming language (OOPS), it uses the concepts of Classes, Objects, Inheritance, Polymorphism and execute a program is non-linear way.

C uses concept of structures (not object oriented), C uses the concept of pointers, and In C the programmer needs to manage memory manually.

 It is so called because we can't write a java program with out using classes & objects. When we compile a Java program, an intermediate bytecode is generated by java complier which itself is interpreted by the Java Virtual Machine This way you write a program once, and the virtual machine translates the bytecode into instructions a specific processor can understand.

Execution of a Java program is by consequence a bit slow, because the intermediate bytecode has to be interpreted.

 Form of Compiled Source Code C executable Native Code 	but Java used byte code to compiler.

Memory management: Manual by using "malloc()" and "free() into C But Java provides a garbage collector to manage memory

Pointers : Are used into C but Not into Java only reference are used at the place of pointers.

Pre-processor: This is pre-processor it C and not into Java.

String Type: String is an array of Characters into C .But in case of Java String type is as Object.

Complex Data Types: Structures, unions are supported by C but into Java Single class inheritance, multiple interface implementations.

Goto Statement is used into C but not into Java.

In C the declaration of variables should be on the beginning of the block. But in Java Variables in Java can be declared anywhere in a program (recommended declare/define them at the beginning of blocks). .

No reuse in code and by default members is public. But Java allow reuse code and defaults members are private .

C is compiled to the”machines native language" so its execution is much faster than Java's.

 C programs will have a larger memory footprint than an equivalent program written in pure machine code, but the total memory use of a C program is much smaller than the a Java program as C use run on complier not require to load an interpreter like the JVM.

 Java's is "writing once run anywhere".


Previous Home Next