Java OCA OCP Practice Question 1344

Question

Suppose you want to run the following command line on a Windows system:

java -classpath somewhere;elsewhere mypkg.bbb.My 

On a Unix system the command line would be:

java -classpath somewhere:elsewhere mypkg.bbb.My 

Assume the CLASSPATH variable is not set. Which must be true in order for the application to run?

  • A. Class My must contain the statement package mypkg.bbb;.
  • B. Class My must be in a directory named mypkg and must contain the statement package bbb;.
  • C. Class My must contain either the statement package somewhere.mypkg.bbb; or the statement package elsewhere.mypkg.bbb;.
  • D. The file My.class must be found either in somewhere\mypkg\bbb or in elsewhere\mypkg\bbb. (Substitute forward slashes for backslashes on a Unix system.)


A, D.

Note

Since the application class name is mypkg.bbb.My, it must declare that it is a member of package mypkg.bbb.

The class file must appear in a subdirectory named mypkg\bbb in one of the directories of the classpath.




PreviousNext

Related