OCA Java SE 8 Building Blocks - OCA Mock Question Building Block 19








Question

Given the following class in the file /my/directory/named/A/Main.java:

      //Main.java
      INSERT CODE HERE 
      public class Main { } 

Which of the following replaces INSERT CODE HERE if we compile from /my/directory? (Choose all that apply)

  1. package my.directory.named.a;
  2. package my.directory.named.A;
  3. package named.a;
  4. package named.A;
  5. package a;
  6. package A;
  7. Does not compile.




Answer



D.

Note

The package name represents any folders underneath the current path, which is named.A in this case.

B is incorrect because package names are case sensitive, just like variable names and other identifiers.