/*************************************************
* Name: Some running env in JAVA
* Author: Hualin Li
* Date: 09/02/2015
* Description: This is some Q and A on JAVA.
*************************************************/

(1)What was the language's original name?... and why was it changed?

Answer: It's Originally called Oak, after the tree that stood outside of Gosling's office, the name was changed because of a copyright already owned by Oak technologies. Other names that were considered were Green, DNA, Silk, Neon, Pepper, Lyric, NetProse, WRL (WebRunner Language), WebDancer, and WebSpinner. 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(2)What was the Green Project?

Answer: This project was initiated in December of 1990, whose aim was to create a programming tool that could render obsolete the C and C++ programming languages. This Stealth Project was later named the Green Project when James Gosling and Mike Sheridan joined Patrick. Over the period of time that the Green Project teethed, the prospects of the project started becoming clearer to the engineers working on it.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(3)What is the origin of the name Java?
It is named by the coffee name which the developers like to drink.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(4)Java was designed to be familiar.What was one consequence of that goal

Answer: Because of that, Java can be programmed without extensive programmer training while being attuned to current software practices. The fundamental concepts of Java technology are grasped quickly; programmers can be productive from the very beginning.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(5)The lack of pointers was a result of which design goal?

Answer: This design leads to simple memory management model, it eliminates entire classes of programming errors that bedevil C and C++ programmers. You can develop Java code with confidence that the system will find many errors quickly and that major problems won't lay dormant until after your production code has shipped.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(6)Why was security a design goal?

Answer:  With security features designed into the language and run-time system, Java technology lets you construct applications that can't be invaded from outside. In the network environment, applications written in the Java programming language are secure from intrusion by unauthorized code attempting to get behind the scenes and create viruses or invade file systems.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(7)What does architecturally neutral and portable mean? What does the Java Virtual Machine have to do with this?

Answer: Neutral and portable means that Java intermediate format designed to transport code efficiently to multiple hardware and software platforms. The interpreted nature of Java technology solves both the binary distribution problem and the version problem; the same Java programming language byte codes will run on any platform.

JVM is an abstract machine for which Java programming language compilers can generate code. Specific implementations of the Java virtual machine for specific hardware and software platforms then provide the concrete realization of the virtual machine.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(8)How does Java's char type differ from that of C? See if you can find out how C++ handles Java-like characters.

Answer: Java language character data is a departure from traditional C. Java's char data type defines a sixteen-bit Unicode character. Unicode characters are unsigned 16-bit values that define character codes in the range 0 through 65,535. By adopting the Unicode character set standard for its character data type, Java language applications are amenable to internationalization and localization, greatly expanding the market for world-wide applications.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(9)What's a difference between Java's boolean and c++ bool data types?

Answer: Java added a Boolean data type as a primitive type, tacitly ratifying existing C and C++ programming practice, where developers define keywords for TRUE and FALSE or YES and NO or similar constructs. A Java boolean variable assumes the value true or false. A Java programming language boolean is a distinct data type; unlike common C practice, a Java programming language boolean type can't be converted to any numeric type.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(10)What are two differences between Java and C++ arrays?

Answer: In contrast to C and C++, the Java programming language arrays are first-class language objects. An array in the Java programming language is a real object with a run-time representation. You can declare and allocate arrays of any type, and you can allocate arrays of arrays to obtain multi-dimensional arrays.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(11)How are strings in Java different than those in C? What about C++?

Answer: Strings are Java programming language objects, not pseudo-arrays of characters as in C. Although strings are Java programming language objects, Java compiler follows the C tradition of providing a syntactic convenience that C programmers have enjoyed with C-style strings, namely, the Java compiler understands that a string of characters enclosed in double quote signs is to be instantiated as a String object. 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(12)What is the multi-level break? Have you ever had a need for one?

Answer: The Java programming language has no goto statement. To break or continue multiple-nested loop or switch constructs, you can place labels on loop and switch constructs, and then break out of or continue to the block named by the label. I use "switch" function() a lot, so, has to use "break" too. 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(13)What is garbage collection? Briefly describe the difference(s) between Java and C++ approaches to memory management?

Answer: Automatic garbage collection is an integral part of Java and its run-time system. While Java technology has a new operator to allocate memory for objects, there is no explicit free function. Once you have allocated an object, the run-time system keeps track of the object's status and automatically reclaims memory when objects are no longer in use, freeing memory for future use.

While for C/C++, they  are by now accustomed to the problems of explicitly managing memory: allocating memory, freeing memory, and keeping track of what memory can be freed when. 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(14)Section 2.2.3 explains why Java has no enum data type. What is an enum? Ironically, enums were introduced into Java at a later release. See if you can find out why.

Answer: An enum type is a special data type that enables for a variable to be a set of predefined constants. The variable must be equal to one of the values that have been predefined for it. Java effectively provides you the concept of qualified enums, all within the existing class mechanisms
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(15)What does section 2.2.4 mean when it says Java has 'no functions'?

Answer: Object-oriented programming supersedes functional and procedural styles. Mixing the two styles just leads to confusion and dilutes the purity of an object-oriented language. Anything you can do with a function you can do just as well by defining a class and creating methods for that class. That is why it is 'no functions" for Java.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(16)Does Java forbid ALL automatic coercions (casts)? What about int to double? Why does Java not allow you to automatically cast (coerce) a double to an int?

Answer: Java prohibits C and C++ style automatic coercions. If you wish to coerce a data element of one type to a data type that would result in loss of precision, you must do so explicitly by using a cast. Java does not allow you to automatically cast (coerce) a double to an int, because it will loose pricision. But int to double is possible.

  
回到主页 回到目录