Anda di halaman 1dari 1

C++ vs Java

There are many differences and similarities between C++ programming language and Java. A list
of top differences between C++ and Java are given below:
Comparison Index
C++
PlatformC++ is platform-dependent.
independent

Java
Java is platform-independent.

Java is mainly used for application


programming. It is widely used in window, webbased, enterprise and mobile applications.
Goto
C++ supports goto statement.
Java doesn't support goto statement.
Java doesn't support multiple inheritance
Multiple inheritance C++ supports multiple inheritance. through class. It can be achieved by interfaces in
java.
Operator
C++ supports operator
Java doesn't support operator overloading.
Overloading
overloading.
Java supports pointer internally. But you can't
C++ supports pointers. You can
Pointers
write the pointer program in java. It means java
write pointer program in C++.
has restricted pointer support in java.
Compiler and
C++ uses compiler only.
Java uses compiler and interpreter both.
Interpreter
Call by Value and C++ supports both call by value Java supports call by value only. There is no call
Call by reference
and call by reference.
by reference in java.
C++ supports structures and
Structure and Union
Java doesn't support structures and unions.
unions.
C++ doesn't have built-in support
Thread Support
for threads. It relies on third-party Java has built-in thread support.
libraries for thread support.
Documentation
C++ doesn't support
Java supports documentation comment (/** ...
comment
documentation comment.
*/) to create documentation for java source code.
C++ supports virtual keyword so Java has no virtual keyword. We can override all
Virtual Keyword
that we can decide whether or not non-static methods by default. In other words,
override a function.
non-static methods are virtual by default.
Java supports unsigned right shift >>> operator
unsigned right shift
that fills zero at the top for the negative
C++ doesn't support >>> operator.
>>>
numbers. For positive numbers, it works same
like >> operator.
Java uses single inheritance tree always because
C++ creates a new inheritance tree all classes are the child of Object class in java.
Inheritance Tree
always.
Object class is the root of inheritance tree in
java.
Mainly used for

C++ is mainly used for system


programming.

Anda mungkin juga menyukai