Java OCA OCP Practice Question 1493

Question

Which of the given options should be inserted at line 1 so that the following code can compile without any errors?

package mypkg; 
// 1 
public class Main{ 
     
    public Main (){ 
         out.println (MAX_VALUE); 
    } 
     
} 

Assume that java.lang.Integer has a static field named MAX_VALUE

Select 2 options

  • A. import static java.lang.Integer.*;
  • B. static import java.lang.System.out;
  • C. static import Integer.MAX_VALUE;
  • D. import static java.lang.System.*;
  • E. static import java.lang.System.*;


Correct Options are  : A D

Note

The order of keywords for a static import must be "import static ... ".

You can either import all the static member using import static

java.lang.Integer.* or one specific member using import static

You must specify the full package name of the class that you are importing.

So, import static Integer.*; is wrong.




PreviousNext

Related