package com.CITC1318.course; public class GreetingsClass { public static void main(String[] args) { System.out.println($ Greetings, CITC1318!); } }
Question:
package com.CITC1318.course;
public class GreetingsClass {
public static void main(String[] args) {
System.out.println("$ Greetings, CITC1318!");
} }
This exercise will have you compiling and running the application with new classes created in a separate package:
1. Compile the program: c:\Code>javac -d . GreetingsClass.java
2. Run the program to ensure it is error-free:
c:\Code>java -cp . com.CITC1318.course.GreetingsClass
3. Create three classes named Chapter1, Chapter2, and Chapter3 that are placed in the com.CITC1318.course.Chapters package. Create constructors that will print the names of the chapters to standard out.
package com.CITC1318.course.Chapters;
public class Chapter1 {
public Chapter1(){
System.out.println("Hello from Chapter1!");
} }
4. Instantiate each class from the main program, by adding the necessary code to the GreetingsClass class. Here is how to instantiate the object c1 from the class Chapter1:
Chapter1 c1 = new Chapter1();
do a c2 from the class Chapter2 and c3 from the class Chapter3.
5. Ensure that all of the class code arein the paths
code\com\CITC1318\courseand code\com\CITC1318\course\Chapters
6. Determine the command-line arguments needed to compile the complete program. Compile the complete program, and debug where necessary.
7. Determine the command-line arguments needed to execute the program. Make sure to update the text file in
The standard output will read as follows:
$ Greetings, CITC1318!
Hello from Chapter1!
Hello from Chapter2!
Hello from Chapter3!
Java How To Program Early Objects
ISBN: 9780134743356
11th Edition
Authors: Paul Deitel, Harvey Deitel