wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes package and import Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "package and import" Watch "package and import" New topic
Author

package and import

adam Lui
Ranch Hand

Joined: Sep 03, 2007
Posts: 186

The class Beta and the enum Color are in different packages.
Which two code fragments, inserted individually at line 2 of the Beta
declaration, will allow this code to compile? (Choose two.)
A. import sun.scjp.Color.*;
B. import static sun.scjp.Color.*;
C. import sun.scjp.Color; import static sun.scjp.Color.*;
D. import sun.scjp.*; import static sun.scjp.Color.*;
E. import sun.scjp.Color; import static sun.scjp.Color.GREEN;

The answers are C and E.

why not B?!! it clearly imports a static content, with full path name.


boolean b = true;<br />System.out.println ("I believe in Java.<br />Java will make my dream come " + b);
ahmed yehia
Ranch Hand

Joined: Apr 22, 2006
Posts: 424
Remember you need to import both enum 'Color' and static member 'GREEN'.
Options C, D and E make valid import statements.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: package and import
 
Similar Threads
enum "initialization circularity"?
import static question
inheritance and polymorphism across packages
Doubt in enums
enums