Differences between C++ and Java

转载 2007年09月25日 12:17:00

C++ Topics and Explanations
Topic: Differences between C++ and Java

[ Follow Ups ] [ Post Follow Up ] [ C++ Topics and Explanations ]

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.

Follow Ups:


Post a Follow Up:




[ Follow Ups ] [ Post Follow Up ] [ C++ Topics and Explanations ]

The Differences Between Java, C And C++

if (!window.netshel_ord) { netshel_ord=Math.random()*10000000000000000;}if (!window.netshel_tile) { ...
  • jianxiong8814
  • jianxiong8814
  • 2007年09月25日 12:21
  • 1200

What's the difference between C++ and Python

In Principle 1. C++ is a "statically typed" language, while Python is a "dynamically typed" languag...
  • bachelorchen
  • bachelorchen
  • 2015年07月20日 11:07
  • 223

6 Major Differences between English and Chinese

There are some basic major differences between English and Chinese. It is important to be aware of t...
  • ansenamerson
  • ansenamerson
  • 2017年08月06日 23:29
  • 470

Differences between L1 and L2 as Loss Function and Regularization

While practicing machine learning, you may have come upon a choice of the mysterious L1 vs L2. Usual...
  • u011650143
  • u011650143
  • 2017年01月23日 15:54
  • 225

Similarities and Differences between Java and C++

 Richard G Baldwin (512) 223-4758, baldwin@austin.cc.tx.us, http://www2.austin.cc.tx.us/baldwin/Simi...
  • jianxiong8814
  • jianxiong8814
  • 2007年09月25日 12:15
  • 884

Topic: Differences between C++ and Java

 转自:http://www.csupomona.edu/~dlbell/cppexplanationsfa99/23.html Posted by Joan Ng on November 14, 1...
  • favorer
  • favorer
  • 2009年07月11日 11:33
  • 230

the differences between groovy and java

Groovy tries to be as natural as possible for Java developers. We’ve tried to follow the principle o...
  • hxpjava1
  • hxpjava1
  • 2017年05月12日 17:03
  • 240

[解题报告]376. Wiggle Subsequence

Problem Background: A sequence of numbers is called a wiggle sequence if the differences between s...
  • Mark__Zeng
  • Mark__Zeng
  • 2016年07月31日 15:59
  • 453

[leetcode] 376. Wiggle Subsequence 解题报告

题目链接: https://leetcode.com/problems/wiggle-subsequence/ A sequence of numbers is called a wiggle s...
  • qq508618087
  • qq508618087
  • 2016年07月22日 05:50
  • 3012


http://mathandmultimedia.com/geogebra/ Mathematics and Multimedia GeoGebra Step-by-Step T...
  • stereohomology
  • stereohomology
  • 2015年05月09日 13:15
  • 1430
您举报文章:Differences between C++ and Java