Question
/* Missing statements ? */
public class NewTreeSet extends java.util.TreeSet
{
public static void main(String [] args)
{
java.util.TreeSet t = new java.util.TreeSet();
t.clear();
}
public void clear()
{
TreeMap m = new TreeMap();
m.clear();
}
}
/* Missing statements ? */
public class NewTreeSet extends java.util.TreeSet
{
public static void main(String [] args)
{
java.util.TreeSet t = new java.util.TreeSet();
t.clear();
}
public void clear()
{
TreeMap m = new TreeMap();
m.clear();
}
}
which two statements, added independently at beginning of the program, allow the code to compile?
1. No statement is required
2. import java.util.*;
3. import.java.util.Tree*;
4. import java.util.TreeSet;
5. import java.util.TreeMap;
Answer: Option B
Was this answer helpful ?
(2) and (5). TreeMap is the only class that must be imported. TreeSet does not need an
import statement because it is described with a fully qualified name.
(1) is incorrect because TreeMap must be imported. (3) is incorrect syntax for an import
statement. (4) is incorrect because it will not import TreeMap, which is required.
Was this answer helpful ?
Submit Solution