Question:
what is difference between java and c++?
2012-12-22 03:06:12 UTC
what is difference between java and c++?
Nine answers:
2012-12-22 03:23:54 UTC
the differences that matter?

1) java has garbage collection, C++ doesn't. that means you have to manage memory usage manually in C++.

2) C++ is compiled, java is interpreted. that means C++ is much faster, because java programs have to be translated as they're run by an interpreter, which is a piece of software running on the computer.
2016-05-18 07:38:12 UTC
Probably the biggest difference between the two is how the languages, when compiled, are handled by the CPU. Java is an 'interpreted' language. Basically, what this means is that when a Java program is ran it runs off of a "virtual machine." This virtual machine application must be on the computer for the program to work. This may seem like a disadvantage, but since the Java program is always running off the same 'virtual machine,' the same program could be ported onto any other platform or OS without any changed to the code. C++, on the other hand, can not be as easily be ported over onto different platforms. However, a self-sustained C++ program, when compiled will work on the computer without any added software. Also, since C++ programs don't require any type of virtual machine, the programs tend to load a lot quicker than a Java program. Some people believe C++ programs are 'quicker' than Java, but I think the jury is still out on that one.
deonejuan
2012-12-22 05:49:50 UTC
Some good answers here. From a programming perspective: Java is a template approach to programming and C++ is linked libraries.



Java requires a plug-in called the JRE. The JRE is an optimized engine that pulls the levers on the various Operating Systems. There is a JRE for 64-bit Windows, another for 32-bit Windows, one for the Mac, one for Solaris, the mainframe computers and the Linux 32- and 64-bit machines. The result is one program file can run across hardware platforms. But, again, the JRE is a pre-requisite. Java produces byte-code so it is NOT an interpreted language.



C++ can make standalone, one-piece software that launch and runs as its own program. However, the same program will have to be recompiled for each of the hardware platforms. Thus, with C++ several versions of the same program must be maintained. If you change the program for the Mac, you will have to update the program for the Windows.



Java is easier to learn. C++ is very powerful once OOPs is comprehended. Java requires OOP.
peteams
2012-12-22 06:30:55 UTC
Java and C++ are superficially similar, they share a common heritage in there syntax. Blocks of code are enclosed in {braces}; statements terminated by semicolons; the basic procedural statements are shared as is the way variables are introduced.



They key difference between C++ and Java is what a compilation unit builds into. In C++ each compilation unit for an executable is done independently and the built units contain very little type information. By contrast in Java each compilation unit is built in concert with the other compilation units and much type information is contained in the target code.



In Java if you have a simple class you write the code once:



class Simpleton { public static int Negate(int x) { return -x; } }



When you compile that the resulting object contains pretty much all the naming and type information you see in the code. The code is written once, client code looks at the compiled code to use it.



In C++ the same class it typically split across two file, a header file containing:



class Simpleton { public: static int Negate(int x); };



That text is then #included into the sources that use and implement it. The implementation might then be:



int Simpleton::Negate(int x) { return -x; }



The split of code seen in C++ is done by the programmer, whereas the split of interface and implementation is done automatically by Java. The fact the programmer can lead to strange effects, both intended and unintended. For example there can be two versions of the header file, that can cause hard to trace problems.



Both C++ and Java are typed languages, the parameter x in my example code is an integer in both. In Java the type of something absolutely enforces how it can be used, you have to work very hard to interpret the pattern of bits that represent an integer as something else. In C++ it is almost trivial to escape the restrictions of the type system, features like reinterpret_cast allow direct access to the underlying bit patterns.



Java has a memory model in which dynamically created objects are tracked, the memory allocated to those objects is tracked and some time after no references to the memory exist the memory is freed. C++ has a built-in model whereby the code has to specify when dynamically allocated memory needs freeing, however you are not forced to use that model and most modern code abandons that for another models.



It is also true that commonly C++ compiles to native code, whereas Java commonly compiles to a byte-code that is interpreted. That is not universally true though, there are compilers for C++ that produce a byte-code and compilers for Java byte-code that produce native code.



C++ is a standard language controlled by various independent standards bodies. Java is a proprietary language created by Sun, but now owned by Oracle after their purchase of Sun; Java has not been submitted to any standards body.
?
2012-12-22 04:27:34 UTC
Difference between Java and C++ :

1. Java does not support operator overloading

2. A class definition in Java looks similar to a class definition in C++, but there is no closing semicolon.

3. Forward reference declarations are not required in Java.

4. Scope resolution operator (::) required in C++ is but not in Java.

5. In C++ you have to re-declare static data members outside the class but such things are not required in Java
2012-12-22 03:13:50 UTC
C++ is older than Java. They are both object oriented programming languages.

Java, C and C++ came from C#



Java is used on billions of devices. Java is more famous than C++. They are both high level languages also. Java is easier to learn. Java was developed by sun microsystems (oracle) in 1995.
Yanni Depp
2012-12-22 03:07:49 UTC
One is Java. The other is C++.
2012-12-22 08:44:25 UTC
java is daughter of c++ its original name was C++minus
Ik
2012-12-23 22:22:49 UTC
google it


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...