C++ vs Java
C++ vs java |
C++ 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 Index
|
C++
|
Java
|
Platform-independent
|
C++ is
platform dependent.
|
Java is
platform-independent.
|
Mainly used for
|
C++ is
mainly used for system programming.
|
Java is
mainly used for application programming. It is widely used in window,
web-based, enterprise and mobile applications.
|
Design Goal
|
C++ was
designed
for systems and application programming. It
was an extension of C programming language.
|
Java was
designed and create as an interpreter for printing systems but later extended
as a support network computing. It was designed with a goal of being easy to
use and accessible to a broader audience.
|
Goto
|
C++
support goto statement
|
Java doesn’t
support goto statement
|
Multiple Inheritance
|
C++ support
multiple inheritance
|
Java doesn’t
support multiple inheritance through class .It can be achieved by interfaces
in java.
|
Pointers
|
C++ support
pointers. You can write pointer program in c++.
|
Java
supports pointer internally. However, you can’t write the pointer program in
java. it means java has restricted support in java.
|
Compile and Interpreter
|
C++ support
only compiler. C++ is compiled and run using the compile which converts
source code into machine code so, C++ is platform dependent.
|
Java user
use compiler and interpreter both. Java source code is converted into
bytecode at compilation time. The interpreted executes this bytecode at
runtime and produce output. Java is interpreted that is why it is platform
independent.
|
Structure and Union
|
C++ support
structure and union.
|
Java
supports call by value only. There is no call by reference in java.
|
Thread Support
|
C++ doesn’t
support have built-in-support for threads. It relies on third-party libraries
for thread support.
|
Java doesn’t
support structure and union.
|
Documentation
comment
|
C++ supports documentation comment.
|
Java supports documentation
comment(/** … */) to create documentation for java source code.
|
Unsigned
right shift>>>
|
C++ doesn’t supports >>>
operator.
|
Java supports unsigned right shift
>>> operator that files Zero at the top for the negative numbers.
For positive numbers, it works same like>> operator.
|
Inheritance
Tree
|
C++ create a new inheritance always.
|
Java uses a single inheritance tree
always because all classes are the child of Object class in java. The object
class is the root of the inheritance tree in java.
|
Hardware
|
C++ is nearer to hardware.
|
Java is not so interactive with
hardware.
|
Object-Oriented
|
C++ is an Object Oriented language.
However, in c language, single root hierarchy is not possible.
|
Java is also an object Oriented
language. However everything (except fundamental types) is an object in Java.
It is a single root hierarchy as everything gets derived form
java.lang.Object.
|
C++ ,Java |
Note:
- · Java doesn’t support default arguments like c++.
C++Example
c++ vs java |
1.
#include<iostream>
2.
Using namespace
std;
3.
Void main() {
4.
Cout<<
“Hello C++ Programming”;
Java Example
java |
1.
class Simple{
2.
public static
void main(String agrs[]){
3.
System.out.println(“Hello
Java”);
4.
}
5.
}
java VS C++
Execution of
c/c++
java VS C++ |
Source code-----compile------machine code-----IBM
only or Windows only
No comments:
Post a Comment