Thursday, 7 December 2017

Difference between C++ and Java

Difference between C++ and Java


C++ supports both procedural and object oriented programming

C++ and Java originate from the same point, i.e. the C language and Both Java and C++ support object oriented programming, yet there are differences between them-
  • C++ is platform-dependent.
  • C++ generates object code and the same code may not run on different platforms.
  • C++ support destructors, which is automatically invoked when the object is destroyed.
  • C++ is mainly used for system programming.
  • C++ uses compiler only.
  • C++ supports structures and unions.
  • C++ supports both method and operator overloading.
  • C++, you may not include the try/catch even if the function throws an exception.
  • C++ has no built in support for threads.

Java is object oriented programming language

  • Java is platform-independent.
  • Java is interpreted for the most part and hence platform independent.
  • Java support automatic garbage collection. It does not support destructors as C++ does.
  • Java is mainly used for application programming. It is widely used in window, web-based, enterprise and mobile applications.
  • Java uses compiler and interpreter both.
  • Java doesn't support structures and unions.
  • Java has method overloading, but no operator overloading.
  • Exception handling in Java is different because there are no destructors. Also, in Java, try/catch must be defined if the function declares that it may throw an exception.
  • Java has built in support for threads.
  • Unlike C++, Java does not support pointers, multiple inheritance, global variables, templates or classes.

0 comments:

Post a Comment