Java OCA OCP Practice Question 1696

Question

Given the following directory structure:.

/proj
  |--- src
  |     |--- A.class
  |
  |
  |--- bin
        |--- top
              |--- mypkg
                     |--- A.class

Assume that the current directory is /proj/src.

Which classpath specifications will find the file A.class for the class top.mypkg.A?

Select the two correct answers.

  • (a) -cp /top/bin/top
  • (b) -cp /top/bin/top/mypkg
  • (c) -cp /top/bin/top/mypkg/A.class
  • (d) -cp ../bin;.
  • (e) -cp /top
  • (f) -cp /top/bin


(d) and (f)

Note

The parent directory (or location) of the package must be specified.

Only (d) and (f) do that.

(d) specifies the current directory as well, but the search is from left to right in the specified paths, resulting in the top.mypkg.A class being found.




PreviousNext

Related