Sunday, July 12, 2009

Could you tell me the difference between C++ and java in detail?

Not in a forum like this. You're talking about a major list of things to talk about. The basic structure and object oriented presentation is the same, but many things are different.





Certain nice things include not having to deallocate allocated objects, when they are not being linked to.





Virtually all objects are instantiated classes, except for the most basic primatives like ints, reals, and chars.





It has a common set of classes similar to C++ libraries.





It is extremely portable. Even 'compiled' code is very portable.

Could you tell me the difference between C++ and java in detail?
Basically they are both object orientated programing languages and are very similar in terms of coding, except the different syntax used that is different in all languages. There are a few suttle differences however:


1) In C++, when you allocate dynamic memory, your program must ensure to return the memory, otherwise you get a memory leak. This is handled automatically in JAVA, but should not be relied upon.


2) Java is compiled to a single format, a format required for the Java Virtual Machine. The Java Virtual Machine (JVM) is the interface between the CPU and your java program. The intent behind this JVM was so you can create and compile your code and it should run on any platform, provided that platform has JVM installed. In C++ for you need to compile code to be used for the platform you are using and this can effect you code implementation.


3) The use of the JVM means your java code is running from an interpreter rather than direct execution by the CPU. This causes your program to be slower than a C++ program.


4) Java is easier to use and learn, but C++ is the prefered Engineering language for speed, programming control, and the abiltiy to drop back into assembly if need be.


No comments:

Post a Comment