708
{
public static voidmain(String[] args)
{
finalString FIRST = "Martin";
finalString MID = "Luther";
finalString LAST = "King";
String name;
name = FIRST + ' '+ MID + ' '+ LAST + " Jr.";
System.out.println(name);
}
}
20.”Sending a message” means telling a method to apply itself to the object or class
to which it is attached—that is, invoking a method.
22.An application
25.The name of a constructor must be identical to the name of the class. Because we
begin class names with uppercase letters, the constructor must also begin with an
uppercase letter.
Chapter 2 Programming Warm-Up Exercises
2.System.out.println("The moon ");
System.out.println("is ");
System.out.println("blue.");
4.System.out.println("Make: "+ make);
System.out.println("Model: "+ model);
System.out.println("Color: "+ color);
System.out.println("Plate type: "+ plateType);
System.out.println("Classification: "+ classification);
5.//******************************************************************
// PrintName application
// This program prints a name in two different formats
//******************************************************************
public classPrintName
{
public static void main(String[] args) throwsIOException
{
String FIRST = "Herman"; // Person's first name
String LAST = "Herrmann";// Person's last name
String MIDDLE = "G"; // Person's middle initial
String firstLast; // Name in first-last format
String lastFirst; // Name in last-first format
String firstInitialLast // Name in first, initial, last format
BufferedReader in; // Input stream for strings
in = newBufferedReader (newInputStreamReader(System.in));
System.out.print("Enter first name: "); // Prompt for first name