Difference Between C++ and Java

By: Rejin Paul
Jun 18,2018
0
{{ postlikes }}
{{ratedCustomerCount}} Post Rating

C++ vs Java

What makes C++ and Java different ? even though they are from same programming paradigm and use object oriented programming . Both are very powerful languages and compare to any other languages the usage of them are high . But what will be the reason to differentiate both and why did they invented Java for the replacement C++. To clarify your doubt have a look into this blog and get your clarification done .

BEGINNING OF C++ :

During 1979 Bjarne Stroustroup found difficulty in integrating classes with the C language . So he did some research as his Ph.d thesis about the working rate of C language . He observed that practically C language not able to develop the actual software and suffered from major object oriented bug problems. So to rectify it he invented C++ with upgraded syntax and structure related to object oriented programming.

HERE COMES JAVA :

James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991.Java was originally designed for interactive television, but it was too advanced for the digital cable television industry at the time.The language was initially called Oak after an oak tree that stood outside Gosling's office. Later the project went by the name Green and was finally renamed Java, from Java coffee .Gosling designed Java with a C/C++ style syntax that system and application programmers would find familiar.

THINGS WHICH JAVA C++ DIFFER :

We know that whenever any new language come into phase it has so many feature than the old one . But Java is partially adapted C++ concepts but the technology and the syntax are completely different.Lets observe what changes they made :

PLATFORM DEPENDENCY :

C++ is a platform dependent because the code can be compiled and run only on that device . But in Java after compilation the byte code is extracted and this code will be used in any system without any compilation . So Java is called platform independent.

- INHERITANCE :

The only change Java made in inheritance is they replaced Multiple Inheritance with Interface because the usage of this inheritance is very high to make easy for the user they made those changes .

- OPERATOR OVERLOADING :

C++ uses operator overloading because it does not have any core api to handle it but Java does not operator overloading because there function system are completely taken care of the compiler.

- HARDWARE INTEGRATION:

Since C++ is an updated version of C it has the ability to integrate with hardware easily but Java is a high level weighted language and its have many layers to work so it cant integrate with hardware more efficiently .

- STRUCTURE AND UNION :

Java does not have structure and union in their structure where else C++ has structure and union as I said C was its parents it inherited some of the structure of it.

- THREAD SUPPORT :

A thread is placeholder information associated with a single use of a program that can handle multiple concurrent users. From the program's point-of-view, a thread is the information needed to serve one individual user or a particular service request.Java supports the thread but C++ does not support this functionality.

- COMPILER & INTERPRETER :

Java source code is converted into byte code at compilation time. The interpreter executes this byte code at run time and produces output.But in C++ there no generation of any byte code it directly compile it and run the program.

- GOTO STATEMENT :

The C++ goto statement is also known as jump statement. It is used to transfer control to the other part of the program. It unconditionally jumps to the specified label.But Java doesn't have these type of statements.

- POINTERS :

The pointer in C++ language is a variable, it is also known as locater or indicator that points to an address of a value.Java supports pointer internally. But you can't write the pointer program in Java. It means Java has restricted pointer support in Java.

- MEMORY MANAGEMENT :

Java has automatic garbage collection function which automatically release all the temporary non-used variables . C++ advanced edition have some functionality like this but not so efficient as Java.

EXAMPLE OF C++ PROGRAM :

#include iostream
#include conio

using namespace std;

// Simple factorial Function
int factorial(int var) {
int fact = 1;
for (int i = 1; i <= var; i++)
fact = fact * i;
return fact;
}

int main() {
cout << "5 Factorial Number :" << factorial(5);
getch();
return 0;
}

EXAMPLE OF JAVA PROGRAM :

class Integers {
public static void main(String[] arguments) {
int c; //declaring a variable

/* Using for loop to repeat instruction execution */

for (c = 1; c <= 10; c++) {
System.out.println(c);
}
}
}

CONCLUSION :

According to C++ philosophy, “WRITE CODE ONCE & COMPILE ANYWHERE” . According to Java philosophy , “WRITE CODE ONCE & RUN ANYWHERE”. I say two are the very powerful languages which are influencing all the software products.Both of the languages have their unique specialty and has the power to be used as general programming language.


Rejin Paul

Hello, Welcome to our Rejinpaul Network. we are Committed to provide educational services for students through our Important Threads in this Website. N.R.Rejinpaul,Founder / Rejinpaul Network working for the welfare of the students since 2010

comments

There is no Comment yet.

comment.username

{{ comment.username }}

{{ comment.date }}
{{ comment.comment }}
leave a comment

{{ commentMsg }}

Please Login & post your comments...

Create Account


This is required.
This is required.
This is required.
This is required.
This is required.
This is required.
This is required.
Male Female
This is required.
School College
This is required.
This is required.
{{registerMsg}}

Log In Your Account


This is required.
This is required.
{{loginMsg}}

Forgot Your Password?

Post Your Rating


your rating : {{ ratings.rating }}

{{ratingMsg}}