OCA Java SE 8 Mock Exam Review - OCA Mock Question 9








Question

Select the correct order of their occurrence in a Java class (choose all that apply):

    1   comments 
    2   import statement 
    3   package statement 
    4   methods 
    5   class declaration 
    6   variables 
  1. 3, 1, 2, 5, 4, 6
  2. 1, 3, 2, 5, 6, 4
  3. 3, 2, 1, 4, 5, 6
  4. 3, 2, 1, 5, 6, 4




Answer



a, b, d

Note

The comments can appear anywhere in a class.

The first statement if present in a class should be a package statement.

Package statement can't be placed after an import statement or a declaration of a class.

The import statement should follow a package statement and be followed by a class declaration.

The class declaration follows the import statements.

It's followed by the declaration of the methods and variables.

C is incorrect. The variables or methods must be defined inside the definition of a class or interface.