/* Missing statements ? */ 
pub

Loading

Practice Operators and Assignments –

/* 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;

     

/* Missing statements ? */ 
pub

Loading

Practice Operators and Assignments –

/* 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;

     

Which statement is true?

Loading

Practice Operators and Assignments –

Which statement is true?

import java.awt.*; 
class Ticke

Loading

Practice Operators and Assignments –

import java.awt.*; 
class Ticker extends Component {
public static void main (String [] args) {
Ticker t = new Ticker();
/* Missing Statements ? */
}
}

which two of the following statements, inserted independently, could legally be inserted into missing section of this code?

  1. boolean test = (Component instanceof t);
  2. boolean test = (t instanceof Ticker);
  3. boolean test = t.instanceof(Ticker);
  4. boolean test = (t instanceof Component);

Which of the following are true statements?

  1. The 

Loading

Practice Operators and Assignments –

Which of the following are true statements?

  1. The Iterator interface declares only three methods: hasNextnext and remove.
  2. The ListIterator interface extends both the List and Iterator interfaces.
  3. The ListIterator interface provides forward and backward iteration capabilities.
  4. The ListIterator interface provides the ability to modify the List during iteration.
  5. The ListIterator interface provides the ability to determine its position in the List.

What will be the output of the program?


			  		

Loading

Practice Operators and Assignments –

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 will be the output of the program?


			  		

Loading

Practice Operators and Assignments –

What will be the output of the program?

import java.util.*;  
class I {
public static void main (String[] args) {
Object i = new ArrayList().iterator();
System.out.print((i instanceof List)+",");
System.out.print((i instanceof Iterator)+",");
System.out.print(i instanceof ListIterator);
}
}

 

Suppose that you would like to create an instance of a new 

Loading

Practice Operators and Assignments –

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?

Which class does not override the equals() and&n

Loading

Practice Operators and Assignments –

Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?

What will be the output of the program?


			  		

Loading

Practice Operators and Assignments –

What will be the output of the program?

String d = "bookkeeper"; 
d.substring(1,7);
d = "w" + d;
d.append("woo"); /* Line 4 */
System.out.println(d);

 

What would be the output of the following program ?

Loading

Practice Operators and Assignments –

What would be the output of the following program ?

class test {
public static void main(String[] args) {
for(int i=0;i<=args.length;i++);
System.out.println(args[i]);
}
}

 

Which of the following two entities (reading from Left to Right) ca

Loading

Practice Operators and Assignments –

Which of the following two entities (reading from Left to Right) can be connected by the dot operator?

Which of the following two entities (reading from Left to Right) ca

Loading

Practice Operators and Assignments –

Which of the following two entities (reading from Left to Right) can be connected by the dot operator?