Short answerEasy2 marks
What is the use of import statement in Java?
Topic: The import statement
Previous-year question practice database
Answer
Exam answer
The import statement makes the classes of a package available to the program, so they can be used without writing their full package name each time.
Example: import java.util.Scanner; lets you write Scanner sc = new Scanner(System.in); instead of java.util.Scanner sc = new java.util.Scanner(System.in);
Explanation
State the purpose and give the example — both are needed for full marks. Two points that show fuller understanding: import java.util.*; brings in every class of that package, and java.lang is imported automatically, which is why String, Math and the wrapper classes need no import at all. The import goes at the very top of the file, before the class definition.
More from Library Classes
What is the output of the statement Math.pow(36, 6/5);?2026The output of the statement:
System.out.println(Character.toUpperCase('b') + 2); is:2026What is the type of parameter to be given for the method parseInt()?2026Write the Java expression to find the sum of cube root of x and the absolute value of y.2026Character class methods are found in the package called:2025The output of Math.max(-7, Math.min(-5, -4)) is2025