Ch1 Welcome to Java Flashcards

1
Q

What package do the Files and Paths class belong to?

A

java.nio.file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Compile and run the following two classes using the java terminal commands:

  • packagea/ClassA
  • packageb/ClassB (contains the main method)
A
  • javac packagea/ClassA.java packageb/ClassB.java
  • java packageb.ClassB
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Where does the javac command place the compiled classes by default?

A

In the same directory as the source code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can we use the javac command to compile ‘packagea/ClassA’ in the directory ‘classes’

A

javac -d classes packagea/ClassA.java

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Compile and run the two classes below using the java terminal commands. Compile them into a directory called ‘classes’.

  • packagea/ClassA
  • packageb/ClassB (contains the main method)
A
  1. javac -d classes packagea/ClassA.java packageb/ClassB.java
  2. java -cp classes packageb.ClassB
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What options are there to specify the classpath to the java or javac command?

A
  • ‘-cp’
  • ‘-classpath’
  • ’–class-path’
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Create a JAR file: ‘myNewFile.jar’ based on the current directory.

A

jar -cvf myNewFile.jar .
– or –
jar –create –verbose –file myNewFile.jar .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Create a JAR file: ‘myNewFile.jar’ based on the directory ‘dir’

A

jar -cvf myNewFile.jar -C dir .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly