Saturday, August 21, 2010

Imports: Find.java

Courtesy of Sun Web Learning Center

 Given two files:


1. package x;
2. public class X {
3.   public static void doX() { System.out.print("doX "); }
4. }

And:


1. class Find {
2.   public static void main(String [] args) {
3.     // insert code here
4.   }
5. }

Which two, inserted independently at line 3 in class Find, will compile and produce the output "doX"? (Choose two.)



A     doX();
B     X.doX();
C     x.X.doX();
D     X myX = new X(); myX.doX();
E     x.X myX = new x.X(); myX.doX();


C and E are correct. Fully qualified names require no import statements. 

No comments:

Post a Comment