OCA Java SE 8 Mock Exam Review - Java Source Code Structure Review

成年女人免费毛片视频-伊人aV 影 伊人網a V在線 VThe structure of a Java class and source code file:

The following sections can be defined within a Java class:

  • import and
  • package statements
  • variables,
  • constructors,
  • methods,
  • comments,
  • nested classes,
  • nested interfaces,
  • annotations, and
  • enums.


成年女人免费毛片视频-伊人aV 影 伊人網a V在線 VIf a class has a package statement, it should be the first statement in the class definition. The package statement can't appear within a class declaration or after the class declaration.

If present, the package statement should appear exactly once in a class.

成年女人免费毛片视频-伊人aV 影 伊人網a V在線 VJava packages group together a related set of classes and interfaces.

成年女人免费毛片视频-伊人aV 影 伊人網a V在線 VBy default, all classes and interfaces in separate packages and subpackages aren't visible to each other.

The package and subpackage names are separated using a dot . sign.

成年女人免费毛片视频-伊人aV 影 伊人網a V在線 VAll classes and interfaces in the same package are visible to each other.


A class can include multiple import statements.

If a class has a package statement, import statements should follow the package statement.

成年女人免费毛片视频-伊人aV 影 伊人網a V在線 VAn import statement allows the use of simple names for packaged classes and interfaces from other packages.

You can't use the import statement to access multiple classes or interfaces with the same names from different packages.

You can import either a single member or all members of a package using the import statement.

成年女人免费毛片视频-伊人aV 影 伊人網a V在線 VYou can't import classes from a subpackage by using the wildcard character in the import statement.

You can import an individual static member of a class or all its static members by using a static import statement.

An import statement can't be placed before a package statement in a class.


Comments are component of a class.

成年女人免费毛片视频-伊人aV 影 伊人網a V在線 VComments are used to annotate Java code and can appear at multiple places within a class.

成年女人免费毛片视频-伊人aV 影 伊人網a V在線 VA comment can appear before or after a package statement, before or after the class definition, and before, within, or after a method definition.

成年女人免费毛片视频-伊人aV 影 伊人網a V在線 VComments has two forms: multiline and end-of-line comments.

Comments can contain any special characters including Unicode charset.

Multiline comments span multiple lines of code. They start with /* and end with */.

成年女人免费毛片视频-伊人aV 影 伊人網a V在線 VEnd-of-line comments start with // and, as the name suggests, are placed at the end of a line of code. The text between // and the end of the line is treated as a comment.


Class declarations and class definitions are components of a Java class.

A Java class may define zero or more instance variables, methods, and constructors.

The order of instance variables, constructors, and methods doesn't matter in a class.

A class may define an instance variable before or after the definition of a method.

Java source file

A Java source code file (.java file) can define multiple classes and interfaces.

A public class can be defined only in a source code file with the same name.

成年女人免费毛片视频-伊人aV 影 伊人網a V在線 Vpackage and import statements apply to all the classes and interfaces defined in the same source code file (.java file).