You are on page 1of 3

3

SREEKANTH 1
JAVA

C++ vs Java
Comparison C++ Java
Index

Platform- C++ is platform- Java is platform-independent.


independent dependent.

Mainly used C++ is mainly used for Java is mainly used for application programming. It is
for system programming. widely used in window, web-based, enterprise and
mobile applications.

Design Goal C++ was designed for Java was designed and created as an interpreter for
systems and applications printing systems but later extended as a support
programming. It was an network computing. It was designed with a goal of being
extension of C easy to use and accessible to a broader audience.
programming language.

Goto C++ supports Java doesn't support the goto statement.


the goto statement.

Multiple C++ supports multiple Java doesn't support multiple inheritance through class.
inheritance inheritance. It can be achieved by interfaces in java.

Operator C++ supports operator Java doesn't support operator overloading.


Overloading overloading.

Pointers C++ supports pointers. You Java supports pointer internally. However, you can't
can write pointer program write the pointer program in java. It means java has
in C++. restricted pointer support in java.

SREEKANTH | Contact No: 7396075960 (EmailID:sreekanthprojects88@gmail.com)


3

SREEKANTH 2
JAVA

Compiler and C++ uses compiler only. Java uses compiler and interpreter both. Java source
Interpreter C++ is compiled and run code is converted into bytecode at compilation time. The
using the compiler which interpreter executes this bytecode at runtime and
converts source code into produces output. Java is interpreted that is why it is
machine code so, C++ is platform independent.
platform dependent.

Call by Value C++ supports both call by Java supports call by value only. There is no call by
and Call by value and call by reference. reference in java.
reference

Structure and C++ supports structures Java doesn't support structures and unions.
Union and 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.

Documentatio C++ doesn't support Java supports documentation comment (/** ... */) to
n comment documentation comment. create documentation for java source code.

Virtual C++ supports virtual Java has no virtual keyword. We can override all non-
Keyword keyword so that we can static methods by default. In other words, non-static
decide whether or not methods are virtual by default.
override a function.

unsigned right C++ doesn't support >>> Java supports unsigned right shift >>> operator that
shift >>> operator. fills zero at the top for the negative numbers. For
positive numbers, it works same like >> operator.

Inheritance C++ creates a new Java uses a single inheritance tree always because all
Tree inheritance tree always. classes are the child of Object class in java. The object
class is the root of the inheritance tree in java.

SREEKANTH | Contact No: 7396075960 (EmailID:sreekanthprojects88@gmail.com)


3

SREEKANTH 3
JAVA

Hardware C++ is nearer to hardware. Java is not so interactive with hardware.

Object- C++ is an object-oriented Java is also an object-oriented language. However,


oriented language. However, in C everything (except fundamental types) is an object in
language, single root Java. It is a single root hierarchy as everything gets
hierarchy is not possible. derived from java.lang.Object

SREEKANTH | Contact No: 7396075960 (EmailID:sreekanthprojects88@gmail.com)

You might also like