Java OCA OCP Practice Question 122

Question

Given that the Integer class is in the java.lang package, and given:

1. // insert code here 
2. class Main { 
3.   public static void main(String[] args) { 
4.     System.out.println(Integer.MAX_VALUE); 
5.   } 
6. } 

Which, inserted independently at line 1, compiles?

Choose all that apply.

  • A. import static java.lang;
  • B. import static java.lang.Integer;
  • C. import static java.lang.Integer.*;
  • D. static import java.lang.Integer.*;
  • E. import static java.lang.Integer.MAX_VALUE;
  • F. None of the above statements are valid import syntax


C and E are correct syntax for static imports.

Note

Line 4 isn't making use of static imports, so the code will also compile with none of the imports.




PreviousNext

Related