What is the difference between CPP (C++) and JAVA?
Answer:
The prime difference between CPP and Java is that CPP is only a compiled language while Java is both compiled and interpreted.
The CPP compiler converts the source code into machine code and therefore, it is platform dependent.
CPP Vs JAVA
Hardware | CPP is nearer to hardware. | Java is not so interactive with hardware. |
---|---|---|
Virtual Keyword | It has Virtual keywords. | It doesn’t have Virtual Keyword. |
Platform Dependency | Platform dependent, needs to be compiled for different platforms. | Platform independent, Java bytecode works on any operating system. |
Portability | CPP is platform dependent. Therefore it is not portable. | It can run in any Operation System therefore it is portable. |
Compilation | CPP is a Compiled Language. | Java is both Compiled and Interpreted Language. |
Memory Management | It is Manual. | It is System Controlled. |
Multiple Inheritance | It supports both single and multiple Inheritance. | It supports only single inheritance. Multiple inheritances are achieved partially using interfaces. |
Overloading | It supports both method and operator overloading. | It supports only method overloading and doesn’t allow operator overloading. |
Pointers | It strongly supports pointers. | It has limited support for pointers. |
Libraries | | |
Documentation Comment | It doesn’t support documentation comments for source code. | It supports documentation comments for source code. |
Thread Support | CPP doesn’t have built-in support for threads, depends on third-party threading libraries. | Java provides built-in support for multithreading. |
Programming Type | CPP is both a procedural and an object-oriented programming language. | Java is only an object-oriented programming language. |
I/O mechanism | CPP uses cin for input and cout for an output operation. | Java uses the (System class): System.in for input and System.out for output. |
goto Keyword | CPP supports goto keyword. | Java doesn’t support goto Keyword |
Structures and Unions | CPP supports Structures and Unions. | Java doesn’t support Structures and Unions. |
Parameter Passing | CPP supports both Pass by Value and pass by reference. | Java supports only the Pass by Value technique. |
Object Management | It supports manual object management using new and delete. | Automatic object management with garbage collection. |
Call by Value and Call by reference | CPP supports both (call by value and call by reference). | Java supports only call by value. |