Questions and Exercises: Getting Started






Questions and Exercises: Getting Started

Questions

1.

When you compile a program written in the Java programming 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.

What is the first thing you should check if at runtime you see the following error?

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

4.

The signature for the main method must contain the keywords public and static. Does the order of these two keywords matter?

5.

The main method accepts a single parameter. By convention, what is this parameter's name?

Exercises

1.

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

2.

Here is a slightly modified version of HelloWorldApp:

// HelloWorldApp2.java

// INTENTIONALLY UNCOMPILABLE!

/**
 * The HelloWorldApp class implements an application that
 * simply prints "Hello World!" to standard output.
 */
class HelloWorldApp2 {
  public static void main(String[] args) {
    System.out.println("Hello World!); // Display the string.
  }
}

The program has an error. Fix the error so that the program successfully compiles and runs. What was the error?

Answers

You can find answers to these Questions and Exercises at:

tutorial/getStarted/QandE/answers.html



 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows