Given the following code:
package p1; public enum Format { JPEG, GIF, TIFF; }
package p1;/*from w w w.jav a 2 s . c o m*/ public class Util { public enum Format { JPEG { public String toString() {return "Jpeggy"; }}, GIF { public String toString() {return "Giffy"; }}, TIFF { public String toString() {return "Tiffy"; }}; } public static <T> void print(T t) { System.out.print("|" + t + "|"); } }
import static p1.Format.*; import static p1.Util.Format; import static p1.Util.print; public class Main { static final int JPEG = 200; public static void main(String[] args) { final int JPEG = 100; print(JPEG);// w w w . ja v a 2s . com print(____________.JPEG); print(____________.JPEG); print(p1._________.JPEG); } }
Which sequence of names, when used top down in the main()
method, will print:
|100||200||Jpeggy||JPEG|
Select the one correct answer.
(c)
We need to access the following:
Main.JPEG (to print 200)
p1.Util.Format.JPEG (to print Jpeggy
). Since p1.Util.Format is statically imported by the second import statement, we need only specify Format.JPEG.
p1.Format.JPEG (to print "JPEG"), which is explicitly specified to distinguish it from other JPEG declarations. The first import statement is actually superfluous.