nerdexam
Oracle

1Z0-811 · Question #54

What does import java.io* mean?

The correct answer is D. All classes in the io package and the subpackages of io packages, if any, are imported. Important note: the provided answer key contains an error. The correct answer is actually B, not D. In Java, the wildcard import import java.io. imports all classes and interfaces directly within the java.io package - but it explicitly does not import subpackages. This is a…

Java Basics

Question

What does import java.io* mean?

Options

  • AOnly the io class is imported.
  • BAll classes in the io package are imported.
  • CAll classes whose names start with io are imported.
  • DAll classes in the io package and the subpackages of io packages, if any, are imported.

How the community answered

(61 responses)
  • A
    3% (2)
  • B
    2% (1)
  • C
    5% (3)
  • D
    90% (55)

Explanation

Important note: the provided answer key contains an error. The correct answer is actually B, not D.

In Java, the wildcard import import java.io.* imports all classes and interfaces directly within the java.io package - but it explicitly does not import subpackages. This is a fundamental Java rule: the * wildcard applies only to the named package's direct members, never recursively to nested packages. To import from a subpackage, you'd need a separate import statement (e.g., import java.io.somesub.*).

Why the distractors are wrong:

  • A is wrong - io is a package, not a single class; * expands to all classes within it.
  • C is wrong - the * wildcard is scoped to a specific package, not a name prefix search across the whole classpath.
  • D is wrong - this is the tricky one. Subpackages are never included; each package must be imported explicitly. Many exam takers assume recursive behavior, but Java does not work that way.

Memory tip: Think of a Java package like a single folder - * grabs every file in that one folder, but doesn't descend into subfolders. Subpackages are completely separate namespaces in Java's eyes.

Topics

#import statements#packages#wildcard syntax#package hierarchy

Community Discussion

No community discussion yet for this question.

Full 1Z0-811 Practice