Sail E0 Webinar
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();
}
}


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;


Options:
A .  1 only
B .  2 and 5
C .  3 and 4
D .  3 and 5
Answer: Option B

(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 ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers