Monday, December 22, 2014

State the main difference between C++ and Java

C++ and Java both are programming languages which are used for developing various types of applications. But the main difference is in their design goals(paradigms) . C++ is a procedure oriented programming language which is derived from structured programming, based upon the concept of the procedure call. Where as java is an Object oriented programming language which relies on java virtual machine (JVM) and provides security and portability. 
The main difference between C++ and java are as follows:

                      C++

                  Java
C++ is partially object oriented programming language

Java is a fully object oriented programming language
Runs as native executable machine code for the target instruction set.
Runs on JVM( java virtual machine)
Pointers are available as part of C++
Pointers are eliminated from java for security reasons
goto statement and typedef are available in C++

goto statement and typedef are eliminated from java because they lead to confusion for a developer.
As part of  C++ we are having constructors and destructors. i.e it is programmers duty to assign and revoke memory for the objects.

As part of java we have only constructors. Here the JVM will take care of de-allocating memory at the time of creating objects.
C++ supports all types of inheritance
Multiple inheritance is not supported by java but there are means to achieve it with the help of interfaces.

Operator overloading is supported by C++
Java will not support operator overloading.

C++ is a platform dependent programming language.
Java is a platform independent programming language.

C++ supports automatic type
conversions.
Java does not support automatic type conversions (except where guaranteed safe).

0 comments:

Post a Comment