Parameter | C++ | Java |
---|---|---|
Relationship | No strict relationship between class names and filenames. In C++, header files and implementation files are used for specific class. | The strict relationship is enforced, e.g., the source code for class PayRoll has to be in PayRoll.java. |
Input mechanism | I/O statements use in and cout, e.g., in » x; cout« y; | I/O input mechanism is a quite complex as it reads one byte at a time (System.in). Output is easy, e.g. System.out.println(x); |
Complier and Interpreter | C++only support compiler | Java supports both compiler and interpreter |
compatibility with other languages | Compatible with C source code, except some exceptional cases. | No backward compatibility with any previous language. The syntax is influenced by C/C++. |
Access control and object protection | Flexible model with constant protection available | The cumbersome model encourages week encapsulation. |
Concept | Write once compile anywhere | Write once run anywhere everywhere |
Support for programming type | Allows both procedural programming and object-oriented programming. | Support object-oriented programming model. |
Interface | Allows direct calls to native system libraries. | Only call through the Java Native Interface and recently Java Native Access |
Memory management | Accessible to programmer | System controlled |
Root hierarchy | C++ there is no such root hierarchy. C++ supports both procedural and object-oriented programming; therefore, it is called a hybrid language. | Java is a pure object-oriented Programming language. That's. Why It follows single root hierarchy. |
Best features | C++ supports Object-oriented features Procedural programming features. | Java support automatic garbage collection. It does not support destructors as C++ does. |
Goto Statement | C++ has a goto statement. Although, it is not ideal to a use a goto statement. | Java has no goto statement. The keywords got, and const are reserved even if they are not used. |
Multiple inheritance | C++ provide multipleInheritance. The keywordvirtual is used to resolveproblems during multipleinheritance if there is any. | Java doesn't provide multiple inheritance. |
Scope resolution operator | C++ has scope resolution operator (: :) which is used to define a method outside of a class and to access a global variable within from the scope where a local variable also exists with the same name. | No scope resolution operator (: :) in Java. The method definitions have to occur within a class, so there is no need for scope resolution. |
Use of try and catch | In C++, you can't include the try/catch even if the function throws an exception. | In Java, Exception handling 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 |
Supporting method | C++ supports both method overloading & operator overloading | Java only supports method overloading. It does not provide support for operator overloading. |
Portability | The source must be recompiled for the platform; hence the code is not portable. | Bytecode classes are transferrable to platform-specific JVM's. |
Type semantics | Consistent between primitive and object types. | Differ for primitive and object types. |
Libraries | Predominantly low-level functionality | Massive, classes for high-level services. |
Runtime error detection | Programmer responsibility. | System Responsibility. |
Supports | Points, structure, and union. | Threads and interfaces. |
Functions & Data | Functions and data may exist external to any class, global and namespace scopes are available. | All function and data exist within classes; package scope are available. |
Platform | C++ programs are platform dependent. They need to be compiled for a particular platform. | Java programs are platform independent. Java programs are written for Java Virtual Machine (JVM). It will run without needing recompilation. |
Runtime error detection | In C++, It is Programmer responsibility to check the errors. | It is system responsibility to check error in the program. |
Pointer | C++ support pointers. | Java offers only limited support for pointers. |
Structure | It supports structures. | It does not any support for structures. |
Unions | C++ supports unions. | Java does not support unions. |
Object management | C++ supports manual object management with the help of new and delete keywords. | Java is heavy depend on automatic garbage collection. It does not support destructors. |
Friday, September 13, 2019
What is difference between C++ and Java?
Subscribe to:
Post Comments (Atom)
How to DROP SEQUENCE in Oracle?
Oracle DROP SEQUENCE overview The DROP SEQUENCE the statement allows you to remove a sequence from the database. Here is the basic sy...
-
1. HTTP OPTIONS Method The HTTP OPTIONS method is used to describe the communication options for the target resource . This method al...
-
Footprinting is a part of reconnaissance process which is used for gathering possible information about a target computer system or networ...
-
Java Comparator interface is used to order the objects of a user-defined class. This interface is found in java.util package and contai...
No comments:
Post a Comment