A. (1 point) Suppose you have a single directory on your CLASSPATH, /Users/stude
ID: 3887956 • Letter: A
Question
A. (1 point) Suppose you have a single directory on your CLASSPATH, /Users/student/src/. That is, the src directory (located inside student, located inside Users) is on your classpath.
Suppose the first line of a Java source file named “Banana.java” is:
package produce.fruits;
Where exactly should this file be located? Specify the full path to the file. For example, a wrong answer is “in /Users/Banana.java”. Another wrong answer is /produce/fruits/Banana.java.
B. (2 points) Suppose we add a file named “Broccoli.java” to the project above, and we want the Broccoli class to reside in the produce.vegetables package. What should the first line (the packagedeclaration) of the Broccoli.java file be? And, what should the full path to the file be?
C. (1 point) Finally, suppose we want to reference the Broccoli class from within the “Banana.java” source. What import statement, if any, do we need to add to the Banana.java file?
thank you!
Explanation / Answer
A. The full path to the file is Users/student/src/produce/fruits/Banana.java
The first line of Banana.java, 'package produce.fruits;', tell that this file will be located in produce/fruits folder under the CLASSPATH
B. The first line should be package produce.vegetables;
And the full path of the file is /Users/student/src/produce/vegetables
C. To import Brocolli.java, we need to include the following import statement in Banana.java
import produce.vegetables.Brocolli;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.