File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes basic difference between c++ and java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "basic difference between c++ and java" Watch "basic difference between c++ and java" New topic
Author

basic difference between c++ and java

samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160
what is the basic diffrence between c++ and java
both :are compiler based language
use :class concept
java uses: jvm compiler
c++ use : turboc++ compiler

both are bject oriented language
in java everything :is object except datatype
than it mde them also wrapper class.
object oriented issues
1. inheritance : parent to child
2. polymorphism : dynamic binding
3. encapsulation : hiding

so my question is :
which language whether c++ or java is more object oriented
in which language we can wisely use reuasble object
Ashok George
Ranch Hand

Joined: Mar 25, 2005
Posts: 87
hi ...
here are my understandings please reply!!!

C++ is not purely an Object Oriented language(OOL)
if aloanguage has to be OOL then it should not support Global functions and Global Data but C++ supports such global things...
and in OOL every thing muct be Objects

java is 99.99% OOL(pure)

it is said so coz in java Primitive data types are not objects!!!

java codes are portable i mean platform independent
whil c++......


THE Other difference is in the case of NAMESPACES!!!.. i am still reading about it!!!

i am not sure !!! of my answers....
just my curiosity made me there!!!
just!!! reply guys!!!
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
Read This
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41601
    
  55
Both C++ and Java have OO features. What matters more than which one has more is how you use those features. In both languages you can write completely procedural code, so even if language A is more OO than language B, any given program written in A might be less OO than another program written in B.

As to the mode of execution (interpreter, compiler, VM, some mixed form), that's largely independent of the language. C/C++ tends to be compiled to native code, Java tends to be compiled to byte code, which is then either interpreted or compiled to native ocde or both at the same time. Other modes are possible for both languages, and they do exist, even if they are largely irrelevant outside of R&D.

i am not sure !!! of my answers....

In that case, maybe you should use fewer exclamation marks


Ping & DNS - my free Android networking tools app
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
Java and C++ have little in common so it's easier to describe where they are alike. Java syntax has a significant overlap with C++ programming syntax. By significant I mean enough to make a line of Java code look familiar to a C++ developer. There was a time when the majority of Java developers were active C++ developers, gradually migrating.

Java is more OO as there are no loose functions or variables declared outside the context of a class definition. C++ can be used to write superior C code that can be compiled directly by an ANSII C compiler. C is entirely procedural.

Interesting side note is that creating object oriented (small 'o') programs in C was an extremely popular and sucessful design pattern. C languages allowed the definition of data records called structs -- short for structure. Skilled software engineers would always define data structures then build functions that operated specifically on those data structures. They would then be delivered as a unit. It was surprisingly simple for the skilled C programmer to move to C++. C++ was just formalizing what they had always done in a more convenient way.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
c++ is much more closer to the implementation of object-oriented theory, as it allows multiple inheritance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41601
    
  55
c++ is much more closer to the implementation of object-oriented theory, as it allows multiple inheritance


OO is not a theory like relational databases are - it's more of a set of concepts. One of those is inheritance, which Java supports. Whether multiple inheritance is a "truer OO" is very much up for debate.
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
>> c++ is much more closer to the implementation of object-oriented theory: allows multiple inheritence.

It's not a generally accepted requirement for object-oriented languages, but Java certainly has it. Java does not have the ability to write an application that uses no object oriented features whatsoever; C++ definitely does.

There are only two issues that I miss from C++ with respect to Java and neither is object-oriented:

1. A more general const modifier:

int safeMemberFunction( String bar ) const

2. Default arguments:

int foo( int x, int y = 0, int z = 0 ) ...

Item one allows for much safer more robust programs.
Item two eliminates this sort of thing:

int foo( int x )
int foo( int x, int y )
int foo( int x, int y, int z)

Variable argument lists are an OK work around.
Rick Portugal
Ranch Hand

Joined: Dec 17, 2002
Posts: 243
Originally posted by Rick O'Shay:
Java and C++ have little in common so it's easier to describe where they are alike. Java syntax has a significant overlap with C++ programming syntax.
Sounds like a contradiction to me. Syntactically, the languages have a lot in common. In practice, the most obvious differences are that C++ allows the developer to use pointers (and pointers to pointers, etc.) and Java does not. Advantage Java. Pointers have been a common source of hard-to-spot bugs.

Also, C++ uses contructors like Java, but C++ also has the concept of DEstructors to delete objects. Java has a garbage collector instead, so the potenial for memory leaks is much less.


IBM 286, SCJP, SCWCD, EIEIO
samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160
Is
using pointers in c++
gives more advantage to c++ over java
 
 
subject: basic difference between c++ and java