Results 1 to 5 of 5

Thread: Differences Between C++ and JAVA

  1. #1
    Join Date
    Nov 2008
    Posts
    1,514

    Differences Between C++ and JAVA

    Here is the list of the differences between C++ and Java.

    C++
    • Overload operators
    • Pointers
    • Naming spaces
    • Multiple inheritance
    • Friend
    • Compilation directive
    • Possibility to write code "sequential" i.e. outside a classroom, as in C


    JAVA
    • Code executed on a virtual machine
    • Interfaces
    • The concept of package
    • The garbage collector


    If you see other things relevant, they are welcome.

    I put the qualifier friend in the list because one day I was explaining that there was a flaw in any case a defect inherent in Java because a developer could not provide classes and prevent one who transmits it to certain things. It's not very well because I remember precisely the explanation. Nevertheless, the solution to this problem exists in C++ with the term precisely friend.

    So my second question is: what is this "fault" of Java which the Java developer confirmed.

  2. #2
    Join Date
    May 2008
    Posts
    1,467

    Re: Differences Between C++ and JAVA

    I know a good technique but is not really a flaw as follows:

    To access a field or private methods, with reflection, we can retrieve a list of all the fields or methods (including private) with Class.getDeclaredFields or Class.getDeclaredMethods.

    Then on the fields or methods (private) interest to us, we call setAccessible (true) then we can recover the value of the field or call the method and it goes!

    It is likely that is what you want to talk, but this is not a flaw at all because we can prevent this kind of code using a SecurityManager which can trigger an exception when using a member setAccessible Private ... So ultimately it is not a flaw but just one thing to know!

  3. #3
    Join Date
    May 2008
    Posts
    979

    Re: Differences Between C++ and JAVA

    Quote Originally Posted by MahaGuru View Post
    Here is the list of the differences between C++ and Java.

    C++
    • Overload operators
    • Pointers
    • Naming spaces
    • Multiple inheritance
    • Friend
    • Compilation directive
    • Possibility to write code "sequential" i.e. outside a classroom, as in C


    JAVA
    • Code executed on a virtual machine
    • Interfaces
    • The concept of package
    • The garbage collector


    If you see other things relevant, they are welcome.

    I put the qualifier friend in the list because one day I was explaining that there was a flaw in any case a defect inherent in Java because a developer could not provide classes and prevent one who transmits it to certain things. It's not very well because I remember precisely the explanation. Nevertheless, the solution to this problem exists in C++ with the term precisely friend.

    So my second question is: what is this "fault" of Java which the Java developer confirmed.
    One thing that you forgot to list in that is the const keyword in C++ that does not exists in Java.

  4. #4
    Join Date
    May 2008
    Posts
    1,467

    Re: Differences Between C++ and JAVA

    Quote Originally Posted by Gunilla View Post
    One thing that you forgot to list in that is the const keyword in C++ that does not exists in Java.
    The const issues in C++ are avoided in Java by convention. You pass only handles to objects and local copies are never made for you automatically. If you want the equivalent of C++'s pass-by-value, you call clone () to produce a local copy of the argument (although the clone () mechanism is somewhat poorly designed). There's no copy-constructor that's automatically called.

    To create a compile-time constant value, you say, for example:

    Code:
    static final int size = 255; 
    static final int bsize = 8 * SIZE;

  5. #5
    Join Date
    May 2008
    Posts
    1,304

    Re: Differences Between C++ and JAVA

    The new additions of Java (Java 1.5) includes:

    • Credits (equivalent to the templates C++)
    • Annotations
    • Loops for style foreach php
    • Auto boxing/unboxing (no equivalents in C++)
    • Listing (object-oriented)
    • Arguments variables (such as C/C++)
    • Typedef nonexistent in Java

    Apart from differences in language, there are also differences in architecture (bytecode jvm):
    • Improved security performance as insulation + verification code in the jvm
    • With Reflection opportunity to 'discover' the unknown class (methods, members ...)
    • Performance and optimizations worse than C++
    • Loading dynamic (at runtime) code with the ClassLoader


    In any case the C++ always keeps its best advantage of being closer to the machine, it is always more effective. And so do not need to install a jre of 15Mb to run a simple "Hello World"

Similar Threads

  1. Differences Between DSL and Cable?
    By Himesh I in forum Hardware Peripherals
    Replies: 4
    Last Post: 02-09-2011, 11:08 AM
  2. userAccountControl differences
    By Pandeyji in forum Software Development
    Replies: 6
    Last Post: 24-09-2010, 05:59 AM
  3. Differences between Java Card and Smart Card
    By Kordell in forum Software Development
    Replies: 5
    Last Post: 23-07-2010, 03:28 AM
  4. Differences between Java and Python
    By Trini Alvarado in forum Software Development
    Replies: 6
    Last Post: 26-05-2010, 11:21 AM
  5. Differences between SATA and IDE
    By Maximus() in forum Hardware Peripherals
    Replies: 2
    Last Post: 04-10-2008, 03:01 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,575,642.17147 seconds with 17 queries