Developed by Y. Daniel Liang using Java Servlets (Current time is Sat Nov 21 11:15:54 EST 2009)

The questions are to accompany Introduction to Java Programming, 4E by Y. Daniel Liang. Please report errors to y.daniel.liang@gmail.com.

Introduction to Java Programming, 4E has been superseded by Introduction to Java Programming, 5E.

Chapter 1: Introduction to Java

Sections 1.8 Creating, Compiling, and Executing a Java Program
1   Suppose you define a Java class as follows:

public class Test {

}

In order to compile this class, the class should be stored in a file named

A. Test.class
B. Test.doc
C. Test.txt
D. Test.java
E. Any name with extension .java

2   The extension name of a Java bytecode file is

A. .java
B. .obj
C. .class
D. .exe

3   The extension name of a Java source code file is

A. .java
B. .obj
C. .class
D. .exe

4   The Java __________ runs a Java program.

A. compiler
B. interpreter
C. program
D. translator

5   The Java __________ compiles a Java program.

A. compiler
B. interpreter
C. program
D. translator

Section 1.9 Anatomy of the Java Program
6   Which of the following lines is not a Java comment?

A. /** comments */
B. // comments
C. -- comments
D. /* comments */
E. ** comments **

7   Which of the following statements is correct?

A. System.out.println('Welcome to Java');
B. System.out.println("Welcome to Java");
C. System.println('Welcome to Java');
D. System.out.print('Welcome to Java');
E. System.out.print("Welcome to Java");

8   A block is enclosed inside __________.

A. Parentheses
B. Braces
C. Brackets
D. Quotes

9   Which of the following is a correct signature for the main method?

A. static void main(String[] args[])
B. public static void main(String[] args)
C. public void main(String[] args)
D. public static void main(Strings[] args)

Section 1.10 Displaying Text in a Message Dialog Box
10   The __________ method terminates the program.

A. System.terminate(0);
B. System.halt(0);
C. System.exit(0);
D. System.stop(0);

11   The __________ method displays a message dialog box.
A. JOptionPane.showMessage(null, "Welcome to Java!", "Example 1.2 Output", JOptionPane.INFORMATION_MESSAGE);
B. JOptionPane.displayMessage(null, "Welcome to Java!", "Example 1.2 Output", JOptionPane.INFORMATION_MESSAGE);
C. JOptionPane.displayMessageDialog(null, "Welcome to Java!", "Example 1.2 Output", JOptionPane.INFORMATION_MESSAGE);
D. JOptionPane.showMessageDialog(null, "Welcome to Java!", "Example 1.2 Output", JOptionPane.INFORMATION_MESSAGE);