what is the difference between c++ and java ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

what is the difference between c++ and java ?

well I'm a new guy, so just wanna understand from you experts. which is the best to go, wheather i choose the c++ or java ? and it gonnabe better and easy for me to choose if you ppl give an elaborate statement on both. Thank you will wait for your valuable responses.

29th Apr 2017, 4:26 AM
Sonu Sharma
Sonu Sharma - avatar
3 Answers
+ 12
Different systems have different compilers, and implementations of the lanugage, and there is no guarantee that C++ program that's written for one platform will perform on another. That's why C++ has got so many cross-platform libraries to make the transition easier.Java on the other hand compiles to the JVM (Java Virtual Machine) bytecode.Java Virtual Machine is an abstraction layer software placed between the physical machine, and the actual program.This in theory allows every Java program to be run on the machine that supports Java without a need to rewrite your program. Their famous moto is"Write once, run anywhere".In practice, it's usually not really like that, but it's still much easier than writing a C++ cross-platform code. C++ gives you all possible styles of programming: procedural, OOP, metaprogramming, functional, etc.Java is somewhat limited in this area.C++ supports multiple class inheritance, while Java only gives you a single class inheritance, but solves the multiplicity via interfaces.C++ has got a pointers, and can directly manipulate/violate the memory addresses.Java is a type-safe language, and you have no availability of pointers in Java. They're present in thebackground, but not on the scene. - Antonio Nesic
29th Apr 2017, 4:33 AM
Agus Mei
Agus Mei - avatar
+ 3
Java is more highlevel than C++, Java has a garbage collector.. you dont need to work with pointers. but you dont have the c++ speed...
29th Apr 2017, 4:32 AM
Esdras Antero
Esdras Antero - avatar
- 2
You can run a java program in every OS (Windows Linux Mac). Instead c works only in Windows
29th Apr 2017, 4:50 AM
Davide Tomasella
Davide Tomasella - avatar