x =if (x1.hashCode() != x2.hashCode() ) x = x +if (x3.equals(x) x = x +if (!x5.equals(x) x = x +if (x7.hashCode() == x8.hashCode() ) x = x +System.out.println("x = " + x);
and assuming that the equals() and hashCode() methods are properly implemented, if the output is "x = 1111", which of the following statements will always be true?class Test{
public int value;
public int hashCode() { return}
}
class Test{
public int value;
public int hashcode() { return (int)(value^5); }
}
which statement is true?Which of the following are true statements?
What will be the output of the program?
public class Test
{
private static float[] f = new float[2];
public static void main (String[] args)
{
System.out.println("f[= " + f[0]);
}
}
What will be the output of the program?
public class Test
{
public static void main (String[] args)
{
String foo = args[1];
String bar = args[2];
String baz = args[3];
System.out.println("baz = " + baz); /* Line 8 */
}
}
And the command line invocation:
> java Test red green blue
Which statement is true for the class java.util.HashSet?
What will be the output of the program?
package foo;
import java.util.Vector; /* Line 2 */
private class MyVector extends Vector
{
int i =/* Line 5 */
public MyVector()
{
i =
}
}
public class MyNewVector extends MyVector
{
public MyNewVector ()
{
i =/* Line*/
}
public static void main (String args [])
{
MyVector v = new MyNewVector(); /* Line*/
}
}
What is the numerical range of char?
Which interface provides the capability to store objects using a key-value pair?
Which statement is true for the class java.util.ArrayList?
What will be the output of the program?
import java.util.*;
class H
{
public static void main (String[] args)
{
Object x = new Vector().elements();
System.out.print((x instanceof Enumeration)+",");
System.out.print((x instanceof Iterator)+",");
System.out.print(x instanceof ListIterator);
}
}
What will be the output of the program?
public class Test
{
public static void main (String args[])
{
String str = NULL;
System.out.println(str);
}
}
Which of the following statements about the hashcode() method are incorrect?
Which of the following are Java reserved words?
Which collection class allows you to associate its elements with key values, and allows you to retrieve objects in FIFO (first-in, first-out) sequence?
What will be the output of the program?
TreeSet map = new TreeSet();
map.add("one");
map.add("two");
map.add("three");
map.add("four");
map.add("one");
Iterator it = map.iterator();
while (it.hasNext() )
{
System.out.print( it.next() + " " );
}
What two statements are true about properly overridden hashCode() and equals() methods?
Which collection class allows you to access its elements by associating a key with an element's value, and provides synchronization?
Suppose that you would like to create an instance of a new Map that has an iteration order that is the same as the iteration order of an existing instance of a Map. Which concrete implementation of the Map interface should be used for the new instance?
What will be the output of the program?
public static void main(String[] args)
{
Object obj = new Object()
{
public int hashCode()
{
return }
};
System.out.println(obj.hashCode());
}