Java OCA OCP Practice Question 1230

Question

If all three top-level elements occur in a source file, they must appear in which order?

  • A. Imports, package declarations, classes/interfaces/enums
  • B. Classes/interfaces/enums, imports, package declarations
  • C. Package declaration must come first; order for imports and class/interfaces/enum definitions is not significant
  • D. Package declaration, imports, class/interface/enum definitions.
  • E. Imports must come first; order for package declarations and class/interface/enum definitions is not significant


D.

Note

Package declaration must come first, followed by imports, followed by class/interface/enum definitions.




PreviousNext

Related