C++ Vs Java - Javatpoint
C++ Vs Java - Javatpoint
https://www.javatpoint.com/cpp-vs-java 1/9
5/18/22, 2:35 PM C++ vs Java - Javatpoint
C++ vs Java
There are many differences and similarities between the C++ programming language and Java. A
list of top differences between C++ and Java are given below:
Mainly used C++ is mainly used for Java is mainly used for application
for system programming. programming. It is widely used in Windows-
based, web-based, enterprise, and mobile
applications.
Design Goal C++ was designed for Java was designed and created as an
systems and applications interpreter for printing systems but later
programming. It was an extended as a support network computing. It
extension of the C was designed to be easy to use and accessible
programming language. to a broader audience.
Goto C++ supports the goto Java doesn't support the goto statement.
statement.
Pointers C++ supports pointers. You Java supports pointer internally. However, you
can write a pointer program can't write the pointer program in java. It
in C++. means java has restricted pointer support in
java.
https://www.javatpoint.com/cpp-vs-java 2/9
5/18/22, 2:35 PM C++ vs Java - Javatpoint
Compiler and C++ uses compiler only. Java uses both compiler and interpreter. Java
Interpreter C++ is compiled and run source code is converted into bytecode at
using the compiler which compilation time. The interpreter executes this
converts source code into bytecode at runtime and produces output.
machine code so, C++ is Java is interpreted that is why it is platform-
platform dependent. independent.
Call by Value C++ supports both call by Java supports call by value only. There is no
and Call by value and call by reference. call by reference in java.
reference
Structure and C++ supports structures and Java doesn't support structures and unions.
Union unions.
Thread C++ doesn't have built-in Java has built-in thread support.
Support support for threads. It relies
on third-party libraries for
thread support.
Documentation C++ doesn't support Java supports documentation comment (/** ...
comment documentation comments. */) to create documentation for java source
code.
Virtual C++ supports virtual Java has no virtual keyword. We can override
Keyword keyword so that we can all non-static methods by default. In other
decide whether or not to words, non-static methods are virtual by
override a function. default.
unsigned right C++ doesn't support >>> Java supports unsigned right shift >>>
shift >>> operator. operator that fills zero at the top for the
negative numbers. For positive numbers, it
works same like >> operator.
Inheritance C++ always creates a new Java always uses a single inheritance tree
Tree inheritance tree. because all classes are the child of the Object
class in Java. The Object class is the root of the
inheritance tree in java.
Note
Java does not support header files like C++. Java uses the import keyword to include
different classes and methods.
#include <iostream>
using namespace std;
int main() {
cout << "Hello C++ Programming";
return 0;
}
Output:
https://www.javatpoint.com/cpp-vs-java 4/9
5/18/22, 2:35 PM C++ vs Java - Javatpoint
class Simple{
public static void main(String args[]){
System.out.println("Hello Java");
}
}
Output:
Hello Java
← Prev
Next →
Youtube
For Videos Join Our Youtube Channel: Join Now
https://www.javatpoint.com/cpp-vs-java 5/9
5/18/22, 2:35 PM C++ vs Java - Javatpoint
Feedback
https://www.javatpoint.com/cpp-vs-java 6/9
5/18/22, 2:35 PM C++ vs Java - Javatpoint
Preparation
Company
Interview
Questions
Company Questions
Trending Technologies
https://www.javatpoint.com/cpp-vs-java 7/9
5/18/22, 2:35 PM C++ vs Java - Javatpoint
B.Tech / MCA
Java tutorial
Java
https://www.javatpoint.com/cpp-vs-java 8/9
5/18/22, 2:35 PM C++ vs Java - Javatpoint
https://www.javatpoint.com/cpp-vs-java 9/9