Java vs C++

S No.
Parameters
C++
Java
1.
Platform Dependency
C++ is platform dependent language.   
Java is platform independent language.
2.
Platform Philosophy
Write once, compile anywhere (WOCA).   
Write once, run anywhere / everywhere (WORA / WORE).
3.
Developer
Bjarne Stroustrup , 1980
James Gosling, Patrick Naughton, Chris Warth, Ed Frank & Mike Sheridan at Sun Microsystems, in 1991.
4.
Original Name
Originally named as "C with Classes" by Bjarne Stroustrup, renamed to "C++" (indicating an increment to C) which is proposed by Rrick Mascitti in 1983.
Originally named as "Oak" by James Gosling, renamed to "Java" 1995.
5.
Evolution
C++ is a superset of C. C++ is evolved from C & simula67.
Java is neither a superset nor a subset of C & C++. It takes some features from C & C++ and also includes some new features too.
6.
Language level
C++ is a middle-level language.
Java is a high-level language.
7.
Extensions
C++ files have extension .cpp
Java files have extension .java
8.
Program Creation
In C++ we can write a program without a class
In Java, there must be at least one class present
9.
Program Compilation
C++ programs can be compiled with variety of compilers.
Java programs can be compiled using an unique compiler.
10.
Source-Code Conversion
Source code is converted directly into machine code(executable code) by compiler.
Source code is converted into byte code by compiler , then byte code is converted into machine code by java interpreter.
11.
Proximity to hardware
C++ is more nearer to hardware than java.
Does not have close interaction with the hardware.
12.
Security
C++ provides data security to an extent.
Java is more secure than C++.
13.
Robust
C++ is less robust as compared with Java
Java is a more robust as compared with C++
14.
Support for comment documentation
C++ does not have built-in support for comment documentation.
Java has built-in support for comment documentation
15.
Built-In Internet Support
C++ does not have built-in support for Internet.   
Java have built-in support for Internet.
16.
Multi-Threading
C++ does not support multi-threaded programming   
Java support multi-threaded programming
17.
Embedding with scripting language
Cannot be embedded in any scripting language.  
Can be embedded within a scripting language by means of applet programming.
18.
Native System Libraries Handling
Allows direct calls to native system libraries.   
Call through the Java Native Interface and Java Native Access
19.
Database Handling
Very complex in C++   
Quite easier than C++
20.
Memory Management
Manual
Managed, using an automatic garbage collector
21.
Automatic Coercions
Yes, with warnings if loss could occur
Not at all if loss could occur, must cast explicitly
22.
Sizes of primitive data types
Varied according to the machine.
Primitive data types have fix size that are machine independent.
23.
Test Expression Outcome(return value)
Test expressions for control flow constructs return an integer value (1/0) in C++.
Test expressions for control flow constructs return a Boolean value (true/false) in Java.
24.
Keywords
There are 63 Keywords in C++
There are 50 Keywords in java.
25.
Array Bounds Checking
An array in C++ is not bounds checked
An array in Java is bounds checked
26.
Namespace
Supported in C++
Java uses packages in place of namespaces.
27.
Call by Address
Supported in C++
Does not supported, java support call by value only
28.
Inline Function
Supported in C++
Does not supported explicitly, java compiler may decide on its own to inline a method, but we don't have much control over this.
29.
Virtual keyword
Supported in C++
There's no virtual keyword in Java because all non-static methods always use dynamic binding.
30.
Exception handling
Supported in C++
Java support Exception handling but it is different from C++ because there are no destructors. A finally clause can be added to force execution of statements that perform necessary cleanup.
31.
Multi-Dimensional Array
Supported in C++
Does not supported in java, but it is possible to create arrays of arrays to represent multi-dimensional arrays.
32.
Goto Statement
Supported in C++
Does not support goto statement
33.
Scope Resolution Operator
Supported in C++
Does not supported in java
34.
Destructors
Supported in C++
Does not supported in java

Comments

Popular posts from this blog

STRUCTURE

FILE HANDLING

WHILE LOOP