google search

Wednesday, January 4, 2012

difference between java and c++ #3

Java can be run anywhere that's the main difference and it available freely. Java has desighn netbeans to support for designing like to to do any project but i n C++ the project is rather tough to built as it doesn't support GUI.

Java uses both Complier and interpreter.

Java is an pure object oriented programming language, it uses the concepts of Classes, Objects, Inheritance, Polymorphism. And the execution of a program is non-linear.
It is so called because you can't write a program with out using classes & objects.

When you compile a Java program, an intermediate bytecode is generated, 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.

Java uses a "Garbage Collector" which manages memory automatically so the programmer doesn't have to handle that.

Variables in Java can be declared anywhere in a program. (Although it is recommended to declare/define them at the beginning of blocks).
Reuse of code achieved by inheritance.
By default members are private.
During the execution of bytecode by JVM, it does not substitute the entire classes of package which are imported in the program. It just enters the package and executes the class and returns result in to the program. Due to this less memory is used by java program.

C uses concept of structures (not object oriented).
In C we use the concept of pointers whereas there are no pointers used in JAVA
In C the programmer needs to manage memory manually. "malloc()" and "free()" are the fundamental memory allocation library calls.
In C the declaration of variables should be on the beginning of the block.
C supports go to statement, struct and union unlike Java
C is compiled to the machines "native language" so it's execution is much faster than Java's.
No reuse in code and by default members are public.
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 because C does not require the loading of an execution interpreter like the JVM.
--------------------------------------------------------------------------------------------

Java
Java is an pure object oriented programming language, it uses the concepts of Classes, Objects, Inheritance, Polymorphism. And the execution of a program is non-linear.
It is so called because you can't write a program with out using classes & objects.

Java's motto (so to speak) is "write once run anywhere".
When you compile a Java program, an intermediate bytecode is generated, 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.

Java uses a "Garbage Collector" which manages memory automatically so the programmer doesn't have to handle that.

Variables in Java can be declared anywhere in a program. (Although it is recommended to declare/define them at the beginning of blocks).
Reuse of code achieved by inheritance.
By default members are private.
During the execution of bytecode by JVM, it does not substitute the entire classes of package which are imported in the program. It just enters the package and executes the class and returns result in to the program. Due to this less memory is used by java program.

C
C uses concept of structures (not object oriented).
In C we use the concept of pointers whereas there are no pointers used in JAVA
In C the programmer needs to manage memory manually. "malloc()" and "free()" are the fundamental memory allocation library calls.
In C the declaration of variables should be on the beginning of the block.
C supports go to statement, struct and union unlike Java
C is compiled to the machines "native language" so it's execution is much faster than Java's.
No reuse in code and by default members are public.
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 because C does not require the loading of an execution interpreter like the JVM.

0 comments:

  © Blogger templates ProBlogger Template by Ourblogtemplates.com 2008

Back to TOP