Java | Difference between C++ and Java

05 min read

Difference between C++ and Java:

  • Java is pure Object Oriented language but C++ is C with Object-oriented extension.
  • All class objects should be dynamically allocated in Java.
  • No operator overloading in java
  • No multiple inheritances but accomplished by a feature called 'interface'.
  •  No template class in Java as in C++
  • Pointers are not present in Java.
  • No global variables. Every variable and method is declared within a class.
  • Header files are not present in Java.
  • The destructor function is not present. Instead finalize() method is used.
  • Java uses call by value to pass all arguments but the effect differs between whether a primitive type or a reference type is passed.
POST A NEW COMMENT
     
  • Input (stdin)

    Output (stdout)


    Input (stdin)

    Your Output (stdout)

    Expected Output

    Compiler Message

    Input (stdin)

    2    3

    Your Output (stdout)

    5

    Expected Output

    5

    Compiler Message

    5

    Error