Bird
0
0

Which of the following import statements correctly imports the Scanner class from the java.util package?

easy📝 Conceptual Q1 of 15
Java - Packages and Access Control
Which of the following import statements correctly imports the Scanner class from the java.util package?
Aimport java.util.Scanner.*;
Bimport java.util.*Scanner;
Cimport java.util.Scanner;
Dimport java.utilScanner;
Step-by-Step Solution
Solution:
  1. Step 1: Understand Java import syntax

    Java imports a specific class using the full package path followed by the class name and a semicolon.
  2. Step 2: Analyze each option

    import java.util.Scanner; uses correct syntax: 'import java.util.Scanner;'. Others have invalid syntax or misplaced wildcards.
  3. Final Answer:

    import java.util.Scanner; -> Option C
  4. Quick Check:

    Correct import syntax = A [OK]
Quick Trick: Use full package path + class name + semicolon for imports [OK]
Common Mistakes:
  • Using wildcard with class name like '*.Scanner;'
  • Omitting semicolon at the end
  • Incorrect package or class name concatenation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes