What is the difference between Java and C++?

There are Various differences between Java and C++. A list of top differences between Java and C++ are given below:

Java

  1. Java is platform-independent.
  2. Java is mainly used for application programming. It is widely used in window, web-based, enterprise and mobile applications.
  3. Java was designed and created as an interpreter for printing systems but later extended as a support network computing. It was designed with a goal of being easy to use and accessible to a wider audience.
  4. Java doesn’t support the goto statement.
  5. Java has built-in thread support.
  6. Java supports documentation comment (/** … */) to create documentation for java source code.
  7. Java has no virtual keyword. We can override all non-static methods by default. In other words, non-static methods are virtual by default.
  8. Java supports unsigned right shift >>> operator that fills zero at the top for the negative numbers. For positive numbers, it works same like >> operator.
  9. Java uses a single inheritance tree always because all classes are the child of Object class in java. Object class is the root of the inheritance tree in java.
  10. Java is not so interactive with hardware.
  11. Java is also an object-oriented language. But in Java, everything (except fundamental types) is an object in Java. It is a single root hierarchy as everything gets derived from java.lang.Object.
  12. Java doesn’t support multiple inheritances through class. It can be achieved by interfaces in java.
  13. Java doesn’t support operator overloading.
  14. Java supports pointer internally. But you can’t write the pointer program in java. It means java has restricted pointer support in java.
  15. Java uses compiler and interpreter both. Java source code is converted into bytecode at compilation time. The interpreter executes this bytecode at runtime and produces output. Java is interpreted that is why it is platform independent.
  16. Java supports call by value only. There is no call by reference in java.
  17. Java doesn’t support structures and unions.

C++

  1. C++ is platform-dependent.
  2. C++ is mainly used for system programming.
  3. C++ was designed for systems and applications programming. It was an extension of C programming language.
  4. C++ supports the goto statement.
  5. C++ doesn’t have built-in support for threads. It relies on third-party libraries for thread support.
  6. C++ doesn’t support documentation comment.
  7. C++ supports virtual keyword so that we can decide whether or not override a function.
  8. C++ doesn’t support >>> operator.
  9. C++ creates a new inheritance tree always.
  10. C++ is more nearer to hardware.
  11. C++ is an object-oriented language. But in C language, single root hierarchy is not possible.
  12. C++ supports multiple inheritance.
  13. C++ supports operator overloading.
  14. C++ supports pointers. You can write pointer program in C++.
  15. C++ uses compiler only. C++ is compiled and run using the compiler which converts source code into machine code so, C++ is platform dependent.
  16. C++ supports both call by value and call by reference.
  17. C++ supports structures and unions.

 

Leave a Reply