0
0
Javaprogramming~15 mins

Import statement usage in Java - Interactive Code Practice

Choose your learning style8 modes available
ads_clickPractice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the ArrayList class from java.util package.

Java
import java.util.[1];

public class Main {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
    }
}
🎯 Drag options to blanks, or click blank then click option
AArrayList
BScanner
CHashMap
DLinkedList
Attempts:
3 left
2fill in blank
medium

Complete the code to import all classes from the java.io package.

Java
import java.io[1];

public class Main {
    public static void main(String[] args) {
        // code using java.io classes
    }
}
🎯 Drag options to blanks, or click blank then click option
A.all
B.*
C.allClasses
D.allFiles
Attempts:
3 left
3fill in blank
hard

Fix the error in the import statement to correctly import the HashMap class.

Java
import java.util.[1];

public class Main {
    public static void main(String[] args) {
        HashMap<String, Integer> map = new HashMap<>();
    }
}
🎯 Drag options to blanks, or click blank then click option
AHashMap
Bhashmap
CHashmap
DhashMap
Attempts:
3 left
4fill in blank
hard

Fill both blanks to import the Scanner class and create a Scanner object.

Java
import java.util.[1];

public class Main {
    public static void main(String[] args) {
        [2] scanner = new Scanner(System.in);
    }
}
🎯 Drag options to blanks, or click blank then click option
AScanner
CArrayList
DHashMap
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to import the List interface, declare a List variable, and initialize it with an ArrayList.

Java
import java.util.[1];
import java.util.[2];

public class Main {
    public static void main(String[] args) {
        [3]<String> list = new ArrayList<>();
    }
}
🎯 Drag options to blanks, or click blank then click option
AList
BArrayList
Attempts:
3 left