What are the main differences between Java and C++?

Everything is an object in Java (Single root hierarchy as everything gets derived from java.lang.Object). Java does not have all the complicated aspects of C++ ( For ex: Pointers, templates, unions, operator overloading, structures etc..) The Java language promoters initially said "No pointers!", but when many programmers questioned how you can work without pointers, the promoters began saying "Restricted pointers." You can make up your mind whether it’s really a pointer or not. In any event, there’s no pointer arithmetic. There are no destructors in Java (automatic garbage collection). Java does not support conditional compile (#ifdef/#ifndef type). Thread support is built into java but not in C++. Java does not support default arguments. There’s no scope resolution operator :: in Java. Java uses the dot for everything, but can get away with it since you can define elements only within a class. Even the method definitions must always occur within a class, so there is no need for scope resolution there either. There’s no "goto " statement in Java. Java doesn’t provide multiple inheritance (MI), at least not in the same sense that C++ does. Exception handling in Java is different because there are no destructors. Java has method overloading, but no operator overloading. The String class does use the + and += operators to concatenate strings and String expressions use automatic type conversion, but that’s a special built-in case. Java is interpreted for the most part and hence platform independent.

Showing Answers 1 - 33 of 33 Answers

Ashish

  • Mar 16th, 2006
 

Java vs C++

1) C++ supports pointers whereas Java does not

2) C++ supports operator overloading,multiple inheritance but java does not.

3) Java is platform independent language but c++ is depends upon operating        system, machine etc.

4) Java uses compiler and interpriter both and in c++ their is only compiler

5) C++ is more nearer to hardware then Java

6) java has premitive data type like boolean which are not available in c++

culver_lake

  • Mar 19th, 2006
 

come on guys.  you don't have anywhere the space to enumerate the differences between Java and c++.

They're 2 different languages. What's the difference between a Ford and a Chevy?

Java is OO from the start. C++ is an example of a language (C) that has OO concepts superimposed (retrofitted) on its basic structure. You can get away with non OO techniques in C++ where Java will give you an error.

  Was this answer useful?  Yes

paul chambakottukudyil

  • Apr 11th, 2006
 

Java is purely object oriented where as C++ is not. Unlike C++,there is no preprocessor for Java.

  Was this answer useful?  Yes

ramki

  • Jan 24th, 2007
 

hey....java doesnt support the concept of multi- threading, where as c++ it supports multi- threading concepts.

  Was this answer useful?  Yes

Deepak Biradar

  • Feb 27th, 2007
 

multiple inheritence is supported in java using interfaces

  Was this answer useful?  Yes

sandy2789

  • Jan 12th, 2009
 

 

Java vs C++

1) C++ supports pointers whereas Java does not

2) C++ supports operator overloading,multiple inheritance but java does not.


3) Java is platform independent language but c++ is depends upon operating        system, machine etc.


4) Java uses compiler and interpriter both and in c++ their is only compiler


5) java has premitive data type like boolean which are not available in c++

  Was this answer useful?  Yes

PraveenSriram

  • Aug 1st, 2011
 

Java supports classes, but does not support structures or unions.

  Was this answer useful?  Yes

sunil kumar

  • Sep 4th, 2011
 

Everything is an object in Java and no of features have been removed from Java like Pointers, templates, unions, operator overloading, structures etc. There’s no scope resolution operator :: in Java. Java uses the dot for everything, but can get away with it since you can define elements only within a class. There’s no "goto " statement in Java. Java doesn’t provide multiple inheritance (MI), at least not in the same sense that C++ does. Java has method overloading, but no operator overloading.

  Was this answer useful?  Yes

what is main diff b/w java and c++

  • Sep 4th, 2011
 

The scope resoultion operatior not supported in java.

Address(&),pointer(*),pointer indirect operators(->) are removed from java

In c++ int have only 2 bytes,but in java int have 4 bytes

  Was this answer useful?  Yes

nithi

  • Sep 12th, 2011
 

C++ allows direct calls to native system libraries but Java call through the Java native interface and recently Java native access.

C++ exposes low level system facilities but Java runs in a protected virtual machine.

  Was this answer useful?  Yes

pranitha

  • Nov 27th, 2011
 

C++ supports unions and structures but Java does not.

  Was this answer useful?  Yes

Mansi pardesi

  • Aug 20th, 2015
 

Why in Java int have 4 bytes and C++ int have 2 bytes

  Was this answer useful?  Yes

himanshu sindhwani

  • Oct 19th, 2016
 

No Java is not purely object oriented as it contains primitive data types

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions