Java OCA OCP Practice Question 772

Question

Given a class that uses the following import statements,

which class would be automatically accessible without using its full package name?

Choose three.


import mypkg1.Bird; 
import mypkg2.tree.*; 
import mypkg3.*; 
A.    mypkg1.Bird
B.    mypkg3.sand.Wave
C.    mypkg2.tree.Main
D.    java.lang.Object
E.    mypkg1.Rectangle
F.    mypkg1.ape.subpkg


A, C, D.

Note

The first import statement allows only the class mypkg1.Bird to be available, making Option A correct and Options E and F incorrect.

Option B is incorrect since the third import statement only allows access to classes within the mypkg3 package, not any sub-packages.

Option C is correct because the second import statement allows any class in the mypkg2.tree package to be accessible.

Option D is correct because java.lang.* is implicitly included in all Java classes.




PreviousNext

Related