Questions and Exercises
Questions
When you compile a program written in the Java language, the compiler converts the human-readable source file into platform-independent code that a Java Virtual Machine can understand. What is this platform-independent code called?
Which of the following is not a valid comment:
/** comment */
/* comment */
/* comment
// comment
In The Java Tutorial, what is the URL of the page that describes Khwarazm? (Hint: You can find the answer by going to http://java.sun.com/docs/books/tutorial/ and clicking on the link to the Search page where you can perform a search.)
-
What is the highest version number of the Java 2 SDK, Standard Edition, that is available for download (early-access releases included)? (Hint: You can find the answer at http://java.sun.com/j2se/)
What is the highest version number for an SDK that you can download and use in shipping products (that is, not an early-access release)?
What is the lowest version number for an SDK that you can download? (Note that "SDK" used to be called "JDK.")
-
Which bug has the highest number of votes at the Java Developer Connection? Give the bug number, description, and number of votes. (Hint: Look for the answer at http://developer.java.sun.com/developer/bugParade/)
Does the bug report give a workaround? If so, what is it?
What is the first thing you should check if the interpreter returns the error:
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp.java.
Exercises
Change the HelloWorldApp.java program so that it displays Hola Mundo! instead of Hello World!
Get the following file from the online Tutorial:
http://java.sun.com/docs/books/tutorial/getStarted/QandE/Useless.java
Compile and run this program. What is the output?
You can find a slightly modified version of HelloWorldApp here:
http://java.sun.com/docs/books/tutorial/getStarted/QandE/HelloWorldApp2.java
The program has an error. Fix the error so that the program successfully compiles and runs. What was the error?
Change the height of the HelloWorld applet from 25 to 50. Describe what the modified applet looks like.
Download the following two source files:
http://java.sun.com/docs/books/tutorial/getStarted/QandE/FirstClass.java
http://java.sun.com/docs/books/tutorial/getStarted/QandE/SecondClass.java
Compile the files, and then run the resulting program. What is the output? If you have trouble compiling the files but have successfully compiled before, try unsetting the CLASSPATH environment variable as described in Path Help (page 540), and then compile again.
Answers
You can find answers to these Questions and Exercises online:
http://java.sun.com/docs/books/tutorial/getStarted/QandE/answers.html