Which package includes the System, String, and Math classes by default?

The story behind the answer

The package that includes the `System`, `String`, and `Math` classes by default is `java.lang`. Java implicitly imports the classes in `java.lang` into every source file, so programs can use names such as `System`, `String`, and `Math` without writing explicit import statements.

The package contains fundamental types closely tied to the language and runtime. `String` represents immutable text, `System` provides standard streams and access to system properties, and `Math` supplies mathematical functions and constants such as `PI`. Other familiar members include `Object`, the implicit superclass of ordinary classes, and wrapper types such as `Integer` and `Boolean`.

“By default” does not mean that every package beneath `java.lang` is automatically available. Only classes directly in `java.lang` receive the implicit import; subpackages still require their own imports. This is why `java.io` is needed for many input/output classes and `java.util` for collections and utilities. Since Java 9, the standard library has also been organized into modules, with most core APIs exported by the `java.base` module.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: