Java OCA OCP Practice Question 41

Question

Which statement about import statements is true?

  • A. The class will not compile if it contains unused import statements.
  • B. Unused import statements can be removed from the class without causing a class to become unable to be compiled.
  • C. The class will not compile if a duplicate import statement is present.
  • D. If a class contains an import statement for a class used in the program that cannot be found, it can still compile.


B.

Note

A class will compile if it has unused or redundant import statements.

Option A and C incorrect.

Option D is also incorrect as the compiler must be able to locate the class of the import statement.

The correct answer is Option B. Removing unused import statements does not cause a class to become unable to be compiled.




PreviousNext

Related