0% found this document useful (0 votes)
8 views

1.4difference Between C and Java 1

Uploaded by

mrnirajbro
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

1.4difference Between C and Java 1

Uploaded by

mrnirajbro
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

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:

Comparison C++ Java


Index

Platform- C++ is platform- Java is platform-


independent dependent. independent.

Mainly used C++ is mainly used Java is mainly used


for for system for application
programming. programming. It is
widely used in
Windows-based,
web-based,
enterprise, and
mobile applications.
Design Goal C++ was designed Java was designed
for systems and and created as an
applications interpreter for
programming. It printing systems but
was an extension of later extended as a
the C programming support network
language. computing. It was
designed to be easy
to use and accessible
to a broader
audience.
Goto C++ supports Java doesn't support
the goto statement. the goto statement.
Multiple C++ supports Java doesn't support
inheritance multiple multiple inheritance
inheritance. through class. It can
be achieved by
using interfaces in
java.
Operator C++ Java doesn't support
Overloading supports operator operator
overloading. overloading.
Pointers C++ Java supports
supports pointers. pointer internally.
You can write a However, you can't
pointer program in write the pointer
C++. program in java. It
means java has
restricted pointer
support in java.
Compiler and C++ uses compiler Java uses both
Interpreter only. C++ is compiler and
compiled and run interpreter. Java
using the compiler source code is
which converts converted into
source code into bytecode at
machine code so, compilation time.
C++ is platform The interpreter
dependent. executes this
bytecode at runtime
and produces output.
Java is interpreted
that is why it is
platform-
independent.
Call by Value C++ supports both Java supports call by
and Call by call by value and value only. There is
reference call by reference. no call by reference
in java.
Structure and C++ supports Java doesn't support
Union structures and structures and
unions. unions.
Thread C++ doesn't have Java has built-
Support built-in support for in thread support.
threads. It relies on
third-party libraries
for thread support.
Documentation C++ doesn't Java supports
comment support documentation
documentation comment (/** ... */)
comments. to create
documentation for
java source code.
Virtual C++ supports Java has no virtual
Keyword virtual keyword so keyword. We can
that we can decide override all non-
whether or not to static methods by
override a function. default. In other
words, non-static
methods are virtual
by default.
unsigned right C++ doesn't Java supports
shift >>> support >>> unsigned right shift
operator. >>> operator that
fills zero at the top
for the negative
numbers. For
positive numbers, it
works same like >>
operator.
Inheritance C++ always Java always uses a
Tree creates a new single inheritance
inheritance tree. 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.
Hardware C++ is nearer to Java is not so
hardware. interactive with
hardware.
Object- C++ is an object- Java is also
oriented oriented language. an object-
However, in the C oriented language.
language, a single However, everything
root hierarchy is not (except fundamental
possible. types) is an object in
Java. It is a single
root hierarchy as
everything gets
derived from
java.lang.Object.

You might also like