Professional Documents
Culture Documents
⇧ SCROLL TO TOP
https://www.javatpoint.com/cpp-vs-java 1/7
3/9/22, 6:19 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 system Java is mainly used for application programming. It is
for programming. widely used in Windows-based, web-based, enterprise,
and mobile applications.
Design Goal C++ was designed for systems and Java was designed and created as an interpreter for
applications programming. It was printing systems but later extended as a support network
an extension of the C programming computing. It was designed to be easy to use and
language. accessible to a broader audience.
Goto C++ supports the goto statement. Java doesn't support the goto statement.
Multiple C++ supports multiple inheritance. Java doesn't support multiple inheritance through class. It
inheritance can be achieved by using interfaces in java.
Pointers C++ supports pointers. You can Java supports pointer internally. However, you can't write
write a pointer program in C++. the pointer program in java. It means java has restricted
pointer support in java.
Compiler and C++ uses compiler only. C++ is Java uses both compiler and interpreter. Java source code
Interpreter compiled and run using the is converted into bytecode at compilation time. The
compiler which converts source interpreter executes this bytecode at runtime and
code into machine code so, C++ is produces output. Java is interpreted that is why it is
platform dependent. platform-independent.
Call by Value C++ supports both call by value Java supports call by value only. There is no call by
and Call by and call by reference. 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 support Java has built-in thread support.
Support for threads. It relies on third-party
libraries for thread support.
2
Documentation C++ doesn't support Java supports documentation comment (/** ... */) to
⇧ SCROLL TO TOP
comment documentation comments. create documentation for java source code.
https://www.javatpoint.com/cpp-vs-java 2/7
3/9/22, 6:19 PM C++ vs Java - Javatpoint
Virtual C++ supports virtual keyword so Java has no virtual keyword. We can override all non-
Keyword that we can decide whether or not static methods by default. In other words, non-static
to override a function. methods are virtual by default.
unsigned right C++ doesn't support >>> Java supports unsigned right shift >>> operator that fills
shift >>> operator. 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 because all
Tree inheritance tree. 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:
⇧ SCROLL TO TOP
https://www.javatpoint.com/cpp-vs-java 3/7
3/9/22, 6:19 PM C++ vs Java - Javatpoint
class Simple{
public static void main(String args[]){
System.out.println("Hello Java");
}
}
Output:
Hello Java
← Prev
Next →
For Videos Join Our Youtube Channel: Join Now
Feedback
⇧ SCROLL TO TOP
https://www.javatpoint.com/cpp-vs-java 4/7
3/9/22, 6:19 PM C++ vs Java - Javatpoint
React Native Python Design Python Pillow Python Turtle Keras tutorial
tutorial Patterns tutorial tutorial
Keras
React Native Python Design Python Pillow Python Turtle
Patterns
Preparation
Trending Technologies
⇧ SCROLL TO TOP
https://www.javatpoint.com/cpp-vs-java 5/7
3/9/22, 6:19 PM C++ vs Java - Javatpoint
Machine DevOps
Learning Tutorial Tutorial
Machine Learning DevOps
Sponsored
B.Tech / MCA
https://www.javatpoint.com/cpp-vs-java 6/7
3/9/22, 6:19 PM C++ vs Java - Javatpoint
Sponsored
Oil Blends You Can Make at Home for All Your
Hair Concerns
Zee Zest
Recommended by
⇧ SCROLL TO TOP
https://www.javatpoint.com/cpp-vs-java 7/7