Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

Questions and Exercises

Questions

  1. 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?

  2. Which of the following is not a valid comment:

    1. /** comment */

    2. /* comment */

    3. /* comment

    4. // comment

  3. 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.)

    1. 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/)

    2. 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)?

    3. What is the lowest version number for an SDK that you can download? (Note that "SDK" used to be called "JDK.")

    1. 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/)

    2. Does the bug report give a workaround? If so, what is it?

  4. What is the first thing you should check if the interpreter returns the error:

Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp.java.

Exercises

  1. Change the HelloWorldApp.java program so that it displays Hola Mundo! instead of Hello World!

  2. 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?

  3. 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?

  4. Change the height of the HelloWorld applet from 25 to 50. Describe what the modified applet looks like.

  5. 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
  • + Share This
  • 🔖 Save To Your Account