Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Fill in the code in Comparable________ c = new Date(); String> ?> E> Date> Which of the following methods are in the Collection interface? remove(o:

Fill in the code in Comparable________ c = new Date();

String>
?>
E>
Date>

Which of the following methods are in the Collection interface?

remove(o: E): boolean
delete(o: E): boolean
deleteAll(c: Collection?>): boolean
removeAll(c: Collection?>): boolean

You can sort an array using the sort method in the Arrays class.

true
false

java.util.Vector is a subtype of ________.

java.util.LinkedList
java.util.ArrayList
java.util.List
java.util.Vector
java.util.AbstractList

What is the output of the following code? import java.util.*; public class Test { public static void main(String[] args) { List list1 = new ArrayList(); list1.add("Atlanta"); list1.add("Macon"); list1.add("Savanna"); List list2 = new ArrayList(); list2.add("Atlanta"); list2.add("Macon"); list2.add("Savanna"); List list3 = new ArrayList(); list3.add("Macon"); list3.add("Savanna"); list3.add("Atlanta"); System.out.println(list1.equals(list2) + " " + list1.equals(list3)); } }

true true
true false
false false
false true

Which method do you use to test if an element is in a set or list named x?

x.in(element)
(element instanceof List) || (element instanceof Set)
x.include(element)
x.contains(element)
x.contain(element)

Suppose set1 is ["Atlanta", "Macon"] and set2 is ["Atlanta", "Macon", "Savannah"], which of the following returns true?

set2.contains(set1)
set1.contains(set2)
set1.contains("Savannah")
set2.contains("Savannah")

Analyze the following code. import java.util.*; public class Test { public static void main(String[] args) throws Exception { Set set = new TreeSet(); set.add("Red"); set.add("Green"); set.add("Blue"); System.out.println(set.first()); } }

The program cannot compile, because the first() method is not defined in Set.
The program may display Red, Blue, or Green.
The program displays Green
The program displays Red
The program displays Blue

If two objects o1 and o2 are equal, what are the values for o1.equals(o2) and o1.hashCode() == o2.hashCode()?

true false
false true
false false
true true

What is the output for the following code? import java.util.*; public class Test { public static void main(String[] args) { Set set = new HashSet(); set.add(new A()); set.add(new A()); set.add(new A()); set.add(new A()); System.out.println(set); } } class A { int r = 1; public String toString() { return r + ""; } public boolean equals(Object o) { return this.r == ((A)o).r; } }

[1]
[1, 1, 1, 1]
[1, 1]
[1, 1, 1]

The printout of the following code is ________. LinkedHashSet set1 = new LinkedHashSet(); set1.add("New York"); LinkedHashSet set2 = (LinkedHashSet)(set1.clone()); set1.add("Atlanta"); set2.add("Dallas"); System.out.println(set2);

[New York, Dallas]
[New York, Atlanta, Dallas]
[New York]
[New York, Atlanta]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Students also viewed these Databases questions