![](http://www.csupomona.edu/~intranet/images/masthead.gif)
![](http://www.csupomona.edu/~intranet/images/logo_black.gif)
C++ Topics and Explanations
Topic: Differences between C++ and Java
Posted by Joan Ng on November 14, 1999 at 18:08:19:
In Reply to: Differences between C++ and Java posted by Approval from Dr. Bell on September 29, 1999 at 22:47:37:
In the evolution of Java, B gave birth to C. C evolved into C++, and C++ transmuted into Java. Java is the language of the Internet. It was conceived by James Gosling, Patrick Naughton, and Mike Sheridan at Sun Microsystems, Inc. in 1990 and took five years to develop.
Java can be used to create two types of programs: applications and applets. The output of a Java compiler is not executable code. Rather it is bytecode. Java run-time system is an interpreter for bytecode. It is simply a highly efficient means of encoding a program for interpretation. It is much easier to allow Java programs to run in a wide variety of environments. Once the run-time package exists for a given system, the bytecode version of any Java program can run on it. Therefore, using bytecode to represent programs is the easiest way to create truly portable programs.
There are two surface similarities between Java and C++. First, Java uses a syntax similar to C++, such as the general forms of the for, while, and do loops. Second, Java supports object-oriented programming, same way as C++.
There are also significant differences from C++, which fundamentally makes Java distinct from C++. Perhaps the single biggest difference between Java and C++ is that Java does not support pointers. Pointers are inherently insecure and troublesome. Since pointers do not exist in Java, neither does the -> operator. Some other C++ features are not found in Java.
Java does not include structures or unions because the class encompasses these other forms. It is redundant to include them.
Java does not support operator overloading.
Java does not include a preprocessor or support the preprocessor directives.
Java does not perform any automatic type conversions that result in a loss of precision.
All the code in a Java program is encapsulated within one or more classes. Therefore, Java does not have global variables or global functions.
Java does not support multiple inheritance.
Java does not support destructors, but rather, add the finalize() function.
Java does not have the delete operator.
The << and >> are not overloaded for I/O operations.
Java does not support templates.
Java shares many similarities with C++ as it relates to classes, but there are also several differences. By default, members of a class are accessible by other members of their class, derived classes, and by other members of their package. Therefore, class members are 搈ore public?than they are in C++, however, the private access specifier applies only to the variable or method that it immediately precedes. All class objects are instantiated in Java using the new operator. Therefore, all class objects are dynamically allocated. When there are no references to an object, then the object is considered inactive.
Java includes two class-management features that help make using and organizing classes easier. The first is called a package, which defines a scope. Therefore, names declared inside a package are private to that package. Java uses file directories to store packages. Therefore, each package must be stored in a directory that has the same name as the package梚ncluding capitalization.
Java, like C++, supports hierarchies of classes. However, the way that inheritance is implemented in Java differs substantially from the way that it is implemented in C++. Since multiple inheritance is not allowed in Java, then Java class hierarchies are linear. In Java, inheritance is referred to as subclassing. A base class in C++ is referred to as superclass in Java.
- Re: Topic: Differences between C++ and Java Pheazin 3/04/5 (
1)
- Re: Topic: Differences between C++ and Java Sagar 3/11/5 (
0)
- Re: Topic: Differences between C++ and Java Sagar 3/11/5 (
0)
- Re: Topic: Differences between C++ and Java Arvind Kannan 2/22/5 (
0)
- Re: Topic: Differences between C++ and Java Ashok 2/01/5 (
0)
- Re: Topic: Differences between C++ and Java fdfd 1/20/5 (
0)
- Re: Topic: Differences between C++ and Java deepak 8/11/4 (
3)
- Re: Topic: Differences between C++ and Java shekhar 12/28/4 (
0)
- Re: Topic: Differences between C++ and Java Nirmal Samal 12/25/4 (
0)
- Re: Topic: Differences between C++ and Java vishal 8/11/4 (
0)
- Re: Topic: Differences between C++ and Java shekhar 12/28/4 (
0)
- Re: Topic: Differences between C++ and Java s.Meenakshi sundaram 8/06/4 (
0)
- Re: Topic: Differences between C++ and Java amita goel 7/30/4 (
0)
- Re: Topic: Differences between C++ and Java baloch khan 7/17/4 (
1)
- Re: Topic: Differences between C++ and Java vineeta 7/28/4 (
0)
- Re: Topic: Differences between C++ and Java vineeta 7/28/4 (
0)
- Re: Topic: Differences between C++ and Java lavanya 7/11/4 (
1)
- Re: Topic: Differences between C++ and Java karthic 2/21/5 (
0)
- Re: Topic: Differences between C++ and Java karthic 2/21/5 (
0)
- Re: Topic: Differences between C++ and Java sachendra_gupta 6/18/4 (
0)
- Re: Topic: Differences between C++ and Java Vernes 6/11/4 (
1)
- Re: Topic: Differences between C++ and Java Sunday 6/12/4 (
0)
- Re: Topic: Differences between C++ and Java Sunday 6/12/4 (
0)
- Re: Topic: Differences between C++ and Java Narayan 5/11/4 (
1)
- Topic: Differences between C++ and Java sunjava 3/06/5 (
0)
- Topic: Differences between C++ and Java sunjava 3/06/5 (
0)
- Re: Topic: Differences between C++ and Java Raghu 4/11/4 (
0)
- Re: Topic: Differences between C++ and Java sankar 3/30/4 (
0)
- Re: Topic: Differences between C++ and Java Pravin Joshi 2/25/4 (
0)
- Re: Topic: Differences between C++ and Java Tejas 2/24/4 (
1)
- Re: Topic: Differences between C++ and Java reddi sekhar 2/13/5 (
0)
- Re: Topic: Differences between C++ and Java reddi sekhar 2/13/5 (
0)
- Re: Topic: Differences between C++ and Java kamran 2/01/4 (
0)
- Re: Topic: Differences between C++ and Java hema 1/24/4 (
0)
- Topic: Differences between C++ and Java Manickam 11/20/3 (
0)
- | Elton 11/10/3 (
0)
- Re: Topic: Differences between C++ and Java Elton Lu 11/10/3 (
1)
- Re: Topic: Differences between C++ and Java chandru 11/14/4 (
0)
- Re: Topic: Differences between C++ and Java chandru 11/14/4 (
0)
- Re: Topic: Differences between C++ and Java parox vaniya 10/14/3 (
0)
- Re: Topic: Differences between C++ and Java Sagar 5/06/3 (
7)
- Re: Topic: Differences between C++ and Java vinit 12/26/3 (
2)
- Re: Topic: Differences between C++ and Java Amol 12/11/4 (
0)
- Re: Topic: Differences between C++ and Java Amol 12/11/4 (
0)
- Re: Topic: Differences between C++ and Java Amol 12/11/4 (
0)
- Re: Topic: Differences between C++ and Java amit kaushik 10/18/3 (
0)
- Re: Topic: Differences between C++ and Java krunal 6/23/3 (
0)
- Re: Topic: Differences between C++ and Java jignesh 6/23/3 (
1)
- Re: Topic: Differences between C++ and Java Yogesh 1/10/5 (
0)
- Re: Topic: Differences between C++ and Java Yogesh 1/10/5 (
0)
- Re: Topic: Differences between C++ and Java vinit 12/26/3 (
2)
- Re: Topic: Differences between C++ and Java sabiha 2/14/3 (
5)
- Differences between C++ and Java pooja 8/25/3 (
1)
- Re: Differences between C++ and Java MIraz 2/08/5 (
0)
- Re: Differences between C++ and Java MIraz 2/08/5 (
0)
- Re: Topic: Differences between C++ and Java purna gunasekera 7/05/3 (
0)
- Re: Topic: Differences between C++ and Java krunal 6/23/3 (
0)
- Re: Topic: Differences between C++ and Java jignesh 6/23/3 (
0)
- Differences between C++ and Java pooja 8/25/3 (
1)
- Re: Topic: Differences between C++ and Java joseph kakonge 11/10/2 (
0)
- Re: Topic: Differences between C++ and Java joey 11/10/2 (
1)
- Re: Topic: Differences between C++ and Java abhi 12/26/3 (
0)
- Re: Topic: Differences between C++ and Java abhi 12/26/3 (
0)
- Re: Topic: Differences between C++ and Java.And their similarities aderemi juyitan 8/24/2 (
3)
- Topic: Differences between C++ and Java. sunil kumar parida 10/13/3 (
1)
- Re: Topic: Differences between C++ and Java. mukesh 7/20/4 (
0)
- Re: Topic: Differences between C++ and Java. mukesh 7/20/4 (
0)
- Re: Topic: Differences between C++ and Java.And their similarities bung hole 8/28/3 (
0)
- Topic: Differences between C++ and Java. sunil kumar parida 10/13/3 (
1)
- Re: Topic: Differences between C++ and Java raheel 2/05/2 (
22)
- Re: Topic: Differences between C++ and Java khanealam 2/20/3 (
6)
- Re: Topic: Differences between C++ and Java Uma 10/01/3 (
1)
- Re: Topic: Differences between C++ and Java mubarak 1/13/4 (
0)
- Re: Topic: Differences between C++ and Java mubarak 1/13/4 (
0)
- Re: Topic: Differences between C++ and Java jigo 6/24/3 (
0)
- Re: Topic: Differences between C++ and Java jignesh 6/23/3 (
0)
- Re: Topic: Differences between C++ and Java jignesh 6/23/3 (
0)
- Re: Topic: Differences between C++ and Java krunal 6/23/3 (
0)
- Re: Topic: Differences between C++ and Java Uma 10/01/3 (
1)
- Re: Topic: Differences between C++ and Java RAYMOND 9/24/2 (
2)
- Re: Topic: Differences between C++ and Java vimal 7/19/3 (
1)
- Decode that Virus 1/14/4 (
0)
- Decode that Virus 1/14/4 (
0)
- Re: Topic: Differences between C++ and Java vimal 7/19/3 (
1)
- Re: Topic: Differences between C++ and Java jennilyn 6/11/2 (
11)
- "why" Multiple inheritance is not allowed in java Aruna.A 8/12/3 (
10)
- Re: "why" Multiple inheritance is not allowed in java Sailaja 6/08/4 (
0)
- Re: pre processor directives in java Lusembo Bob Paul 5/06/4 (
0)
- Re: "why" Multiple inheritance is not allowed in java Paramita 3/25/4 (
1)
- Re: "why" Multiple inheritance is not allowed in java Ashok kumar 5/21/4 (
0)
- Re: "why" Multiple inheritance is not allowed in java Ashok kumar 5/21/4 (
0)
- Re: "why" Multiple inheritance is not allowed in java Nagesh 1/28/4 (
0)
- Re: "why" Multiple inheritance is not allowed in java prashant jain 11/03/3 (
2)
- Re: "why" Multiple inheritance is removed from java don't explain about c++ naveen loya 11/26/4 (
0)
- Re: "why" Multiple inheritance is not allowed in java Aqeel 3/12/4 (
0)
- Re: "why" Multiple inheritance is removed from java don't explain about c++ naveen loya 11/26/4 (
0)
- Re: "why" Multiple inheritance is not allowed in java prashant jain 11/03/3 (
0)
- Re: Madan Mohan 9/27/3 (
0)
- Re: "why" Multiple inheritance is not allowed in java Sailaja 6/08/4 (
0)
- "why" Multiple inheritance is not allowed in java Aruna.A 8/12/3 (
10)
- Re: Topic: Differences between C++ and Java khanealam 2/20/3 (
6)
- Take Print Out : Differences between C++ and Java Manjax 7/31/1 (
1)
- how main is called sreenivas 8/23/3 (
0)
- how main is called sreenivas 8/23/3 (
0)
- Take Print Out : Differences between C++ and Java Mahesh 7/31/1 (
0)
- Take Print Out : Differences between C++ and Java Mahesh 7/31/1 (
1)
- Re: Take Print Out : Differences between C++ and Java Vishal 8/20/4 (
0)
- Re: Take Print Out : Differences between C++ and Java Vishal 8/20/4 (
0)
Post a Follow Up:
Subject:
Comments: