Difference between Java and C++
Categories: Core Java C++
Java is a platform independent language language. But c++ is not a platform independent language it depend on operating system machine.
Java does not support multiple inheritance but, c++ support multiple inheritance.
java does not support pointer, union, structure, templates, operator overloading but, c++ is support pointer, union, structure, templates, operator overloading and pointer arithmetic.
java uses compiler and interpreter both but, c++ is use compiler only.
At compilation time java program first java source code is compile then generate byte code means (.class ) and after interpreted convert the machine code before execution. But c++ run and compile uses compiler which convert source code into machine language.
Java has support method overloading but not support operator overloading. C++ support both method overloading and operator overloading.
Java has primitive data type like boolean which are not available in c++.
java has support documentation comment( /**............*/ ) , but c++ is not support documentation comment.
Java does not support scope resolution operator (: :), But c++ is support resolution operator.
Java does not support goto (but goto is reversed word).
C++ is more nearer to hardware then java.
Java does not support unsigned integer.
Java does not support global variable.
Thread support built in java but not c++.
Java does not support header file just like c++. it use import to add the class and interrface.
Exception and Auto Garbage Collector handling in Java is different because there are no destructors into Java.
Parameters | Java | C++ |
---|---|---|
Founder | Java was developed by James Gosling at Sun Microsystems. | C++ was developed by Bjarne Stroustrup at Bell Labs since 1979 as an extension of the C language. |
First Release | On May 23, 1995 | In October 1985 |
Stable Release | Java SE 14 or JDK 14 was released on March 17, 2020. | C++17 was released in December 2017. |
Official Website | oracle.com/java | isocpp.org |
Influenced By: | Java was Influenced by Ada 83, Pascal, C++, C#, etc languages. | C++ was Influenced by Influenced by Ada, ALGOL 68, C, ML, Simula, Smalltalk etc language. |
Influenced to: | Java was influenced to develop BeanShell, C#, Clojure, Groovy, Hack, J#, Kotlin, PHP, Python, Scala, etc languages. | C++ was influenced to develop C99, Java, JS++, Lua, Perl, PHP, Python, Rust, Seed7, etc languages. |
Platform Dependency | Platform independent, Java bytecode works on any operating system. | Platform dependent should be compiled for different platforms. |
Portability | It can run in any OS hence it is portable. | C++ is platform-dependent hence it is not portable. |
Compilation | Java is both Compiled and Interpreted Language. | C++ has only Compiled Language. |
Memory Management | Memory Management is System Controlled. | Memory Management in C++ is Manual. |
Virtual Keyword | It doesn’t have Virtual Keyword. | It has Virtual Keyword. |
Multiple Inheritance | It supports only single inheritance. Multiple inheritances are achieved partially using interfaces. | It supports both single and multiple Inheritance. |
Overloading | It supports only method overloading and doesn’t allow operator overloading. | It supports both methods and operators overloading. |
Pointers | It supports limited support for pointers. | It strongly supports Pointer. |
Libraries | It doesn’t support direct native library calls but only Java Native Interfaces. | It supports direct system library calls, making it suitable for system-level programming. |
Libraries | libraries have a wide range of classes for various high-level services | C++ libraries are comparatively low-level functionalities. |
Documentation Comment | It supports documentation comment (e.g, /**.. */) for source code. | It doesn’t support documentation comments for source code. |
Thread Support | Java supports documentation comment (e.g, /**.. */) for source code | C++ doesn’t have built-in support for threads, depends on third-party threading libraries. |
Type | Java is the only object-oriented programming language. | C++ is both a procedural and object-oriented programming language. |
Input-Output mechanism | Java uses the (System class) System.in for input and System.out for output. | C++ uses cin for input and cout for an Output operation. |
goto Keyword | Java doesn’t support goto Keyword | C++ supports goto keyword. |
Structures and Unions | Java doesn’t support Structures and Unions. | C++ supports Structures and Unions. |
Parameter Passing | Java supports only the Pass by Value technique. | C++ supports both Pass by Value and pass by reference. |
Global Scope | It supports no global scope. | It supports both global scope and namespace scope. |
Object Management | Automatic object management with garbage collection. | It supports manual object management using new and deletes. |