Techno programmer
int[] myArray = new int[] {1, 2, 3, 4, 5};
What allows you to create a list from this array?
A List myList = myArray.asList();
B List myList = Arrays.asList(myArray);
C List myList = new ArrayList(myArray);
D List myList = Collections.fromArray(myArray);
public static Iterator reverse(List list)
{
Collections.reverse(list);
return list.iterator();
}
public static void main(String[] args)
{
List list = new ArrayList();
list.add("1"); list.add("2"); list.add("3");
for (Object obj: reverse(list))
System.out.print(obj + ", ");
}
What is the result?
A 3, 2, 1,
B 1, 2, 3,
C Compilation fails.
D The code runs with no output.
E An exception is thrown at runtime.
import java.util.*;
public class Example
{
public static void main(String[] args)
{
// insert code here
set.add(new Integer(2));
set.add(new Integer(1));
System.out.println(set);
}
}
Which code, inserted at line 4, guarantees that this program will output [1, 2]?
A Set set = new TreeSet();
B Set set = new HashSet();
C Set set = new SortedSet();
D List set = new SortedList();
E Set set = new LinkedHashSet();
Click here to claim your Sponsored Listing.
Category
Contact the school
Telephone
Website
Address
Hyderabad