| C++ | Java |
|---|---|
| C++ is an extension of C with object-oriented behavior. | Java is a true and complete object-oriented language. |
| It offers template classes. | It does not provide template classes. |
| It achieves multiple inheritance by permitting classes to inherit from multiple classes. | It supports multiple inheritance using interfaces. |
| Global variables can be declared in C++. | It does not provide global variables. |
| It supports pointers. | It does not support pointers. |
| In C++, destruction of object is performed by destructor function. | In java, destruction of objects is performed by finalize method. |
| It has header files. | It doesn’t provide header file. |
| It supports operator overloading. | It does not support operator overloading. |
| The test expressions for control flow constructs return an integer value. | The test expressions for control flow constructs return a Boolean value. |
| There is scope resolution operator (: :) in C++. | There is no scope resolution operator in java. |
| It does not support documentation comments. | It has built in support for documentation comments (/**………*/). |
| It is compiled directly to machine code which is then executed directly by the central processing unit. | It is compiled to byte – code which the Java Virtual Machine (JVM) then interprets at runtime. |
| It does not support multithreading. | It supports multithreading. |
| It supports go to statement. | It does not support go to statement. |
| Virtual keyword is present in C++. | There is no virtual keyword. |
| String in C++ are array of characters. | Strings in java are objects. |
| Strings are terminated by null character. | Strings are not terminated by null character. |
| It supports structures or unions. | It does not support structures or unions. |
| It only uses compiler. | It uses both compiler and interpreter. |
| It doesn’t use packages. | It uses packages. |
| It has a preprocessor. | It does not have a preprocessor. |
| It is mainly used for developing system software. | It is mainly used for developing applets. |
| It supports storage classes like auto, extern etc. | It does not support storage classes. |
| It supports default arguments. | It does not support default arguments. |
| It supports typedef keyword. | It does not support typedef keyword. |
| Inline functions can be made in C++. | There are no inline functions in java. |
| It generates object code and the same code may not run on different platforms. | It is interpreted for the most part hence platform independent. |
| We may not include the try/catch even if the function throws an exception. | In java, try/catch must be defined if the function declares that it may have thrown an exception. |
| It has low portability. | It has high portability. |
| It supports multi-dimensional arrays. | It does not support multidimensional arrays. However, it is possible to create arrays of arrays to represent multidimensional arrays. |
| Standard output example in C++, cout<<”Hello”; | Standard output example in java, System.out.print(”Hello”); |
No comments:
Post a Comment