Respuesta :

Answer: The compiler automatically imports the java.lang package.

Explanation:

Java packages are defined as a collection of classes, interfaces, and the like. Java programs utilize the components in the packages to implement their functionalities. Packages are either imported by the compiler or by the user through import keyword. The user can import any package using the import keyword. The import statements are always written at the beginning of the program.

import java.math.* ;

For example, the programmer writes the above statement that imports the java.math package into the java program.

Default packages are automatically imported by the compiler.

Default packages include java.lang packages. This default package is made up of all the classes and functions that are mandatory to any java program. Without java.lang package, the java program cannot be compiled and hence, becomes useless. The Java compiler adds the import statement for the default package, java.lang, at the beginning of the compilation. Hence, the statement

import java.lang.*;

does not needs to be written in the program.

The java.lang package consists of useful components which are required for various operations that can be done on the datatypes found in Java language. This package consists of classes and functions which relates to each data type and defines the functions which can be utilized to perform the operations allowed for the respective data types.

The java.lang package consists of Object, String, Math, System, Thread, Exception classes and wrapper classes like Integer, Double etc.. All the operations that can be implemented on the above-mentioned data types utilize the functions defined in their respective classes.

For example, printing on the console is done using System class.

System.out.println();

Also, all the operations done on strings use the methods such as append(), insert(), delete(), and replace(), etc, are pre-defined in the String class in the java.lang package.

Without java.lang package, any Java program cannot be useful.