Java OCA OCP Practice Question 803

Question

What statements are true about compiling a Java class file? (Choose two.)

  • A. If the file does not contain a package statement, then the compiler considers the class part of the java.lang package.
  • B. The compiler assumes every class implicitly imports the java.lang.* package.
  • C. The compiler assumes every class implicitly imports the java.util.* package.
  • D. Java requires every file to declare a package statement.
  • E. Java requires every file to declare at least one import statement.
  • F. If the class declaration does not extend another class, then it implicitly extends the java.lang.Object class.


B, F.

Note

A class may be defined without a package statement, making the class part of the default package.

Options A and D are incorrect.

Every Java class implicitly imports exactly one package, java.lang.*, making Option B correct and Option C incorrect.

Option E is incorrect because an import statement is not required.

Option F is correct; any class that does not extend another class implicitly extends java.lang.Object.




PreviousNext

Related