Java OCA OCP Practice Question 404

Question

Given the following:

package pack; //from   ww  w . j  a  v  a  2 s .  c  om

class MyClass { 
  public int                a; 
  public static int         b; 
  int                       c; 
  static int                d; 

  public void        e() { } 
  public static void f() { } 
} 

Which of the following features of class MyClass may be accessed by a class, in package pack, as a result of the following import?

import static pack.MyClass.*; 
  • A. a
  • B. b
  • C. c
  • D. d
  • E. e()
  • F. f()


B, D, F.

Note

A static import does not apply to non-static features, so A, C, and E are ruled out.

Since the class performing the import is in the same package as MyClass, all static features (data and methods) that have public, protected, or default access are imported into the importing class' namespace.




PreviousNext

Related