• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package and import

 
adam Lui
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
ahmed yehia
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember you need to import both enum 'Color' and static member 'GREEN'.
Options C, D and E make valid import statements.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic