Difference Between C++ and Java In Table – Java Tutorial

Difference Between C++ And Java In Points

C++ and Java both support object oriented programming but there are lots of similarities and difference between C++ and Java.

Java is designed to run same source code on various platforms. Java code is compiled into bytecode. The bytecode runs on any JVM (Java Virtual Machine).

Java inherits syntax from C language and structure from C++ language. Java has a huge collection of the standard library is written in OOP. But In C++ library is smaller and some parts of the library are inherited from C is not OOP.

C++ and Java both support constructor. But the process of the invoke is different for both. Java constructor invokes without new() operator by JVM.

The main difference between C++ and Java. – C++ is the platform dependent programming language and Java is the platform dependent programming language.

difference between c++ and java

The major difference between C++ and Java in tabular form

C++ Java
C++ is procedural and object-oriented programming language. Java is pure object oriented programming language.
C++ is a platform dependent programming language. Because C++ need to compiled for a particular platform. Java is platform independent programming language. It works on any type operating system where JVM is installed.
C++ is a multiparadigm language with support of OOP. Java is OOP language is forces you to write code in OOP style.
C++ is mainly used for design desktop application. Java is mainly used for design web based, mobile, windows and enterprise applications.
C++ support the concept of a pointer. Java does not support the concept of Pointer. Pointers are supported internally but you can not able to declare a pointer in programs. Java supports References is act like pointers in C++. References cannot interpret as raw address and you can not perform arithmetic operations on pointers.
C++ support destructors, which is automatically invoked when the object is not longer to referenced and destroy the object. It also supports delete and new keyword for manage object. Java does not support destructors to destroy the object. It supports the concept of automatic garbage collection.
C++ supports goto statement. But the use of the goto statement in the program is very difficult to understand. Java does not support goto statement. It supports unconditional jump mechanism is the break and continue statement is used to jump the loops.
The process of destruction is performed by destroy() method. The process of destruction is performed in finalized method.
C++ supports the concept of the multiple inheritances through class. It can implement with the help of classes. The keyword virtual used in multiple inheritances for solve ambiguities. Java does not support multiple inheritances. Although it can be achieved by interfaces.
It provides header files. It does not provide header files.
C++ supports both operator and method overloading. Java support method overloading but doesn’t support for operator overloading.
C++ uses the only compiler. Java uses both compiler and interpreter.
It supports both call by value and call by reference. It supports only call by value. There is no any concept of the call by reference.
C++ does not provide support for documentation comment. It has built-in support for documentation comment to create documentation. You can write comments using /** … */
C++ supports structures, Enums and unions. Java does not provide support for structures, Enums and unions.
It always creates a new inheritance tree. It always uses single inheritance tree.
C++ support default argument. The scope resolution operator used to define a method outside of the class. Java has no scope resolution operator (::). It does not support default arguments. The methods can only define in class.
C++ supports virtual keyword to decide whether or not override method. It does not support virtual keyword. Override non-static methods by default.
C++ does not support threads. It relies on third-party libraries for support. Java provides built-in thread support. Thread class need to inherited for creating a new thread.
C++ does not provide support for unsigned right shift operator (>>>). Java supports unsigned right shift operator. logical right shift by inserting zero at the top end for negative numbers.
It support conditional inclusion such as #ifdef #ifndef. Java does not support conditional inclusion and compilation.
C++ was developed by Bjarne Stroustrup in 1979. Java was developed by James Gosling in 1991.
Categories: Java Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *