Java v/s C++

Apart from being platform independent , what are the other features that makes Java a better approach than C++?

  • Nishith
  • 08 जुलाई
  • 4231 दृश्य
  • 4 उत्तर
Your Answer

  C++ is compatible with C source code, whereas, java provides the Java Native Interface and recently Java Native Access as a way to directly call C/C++ code. C++ is Write once, compile anywhere, as Java is Write once, run anywhere/everywhere. C++ runs as native executable machine code for the target instruction set as java runs in a virtual machine. In terms of conversion, allows explicitly overriding types as well as some implicit narrowing conversions(for compatibility with C) but, java strongly follows rigid type safety except for widening conversions. C++ uses single and multiple inheritance of classes, including virtual inheritance and java uses single inheritance of classes. Supports multiple inheritance via the Interfaces construct, which is equivalent to a C++ class composed of abstract methods. In C++, const keyword for defining immutable variables and member functions that do not change the object. Being Const is propagated as a means to enforce, at compile-time, correctness of the code with respect to mutability of objects as in java, final provides a version of const, equivalent to type* const pointers for objects and const for primitive types. Immutability of object members achieved through read-only interfaces and object encapsulation.

0
programming in java
मॉक परीक्षण अभ्यास के लिए
programming in java