Given:
HashMap props = new HashMap();
props.put(key45, some value);
props.put(key12, some other value);
props.put(key39, yet another value);
Set s = props.keySet();
//insert code here
What, inserted at line 39, will sort the keys in the props HashMap?
public class TestOne implements Runnable {
public static void main (String[] args) throws Exception {
Thread t = new Thread(new TestOne());
t.start();
System.out.print(Started);
t.join();
System.out.print(Complete);
}
public void run() {
for (int i = 0; i < 4; i++) {
System.out.print(i);
}
}
}
What can be a result?
Given:
Runnable r = new Runnable() {
public void run() {
System.out.print("Cat");
}
};
Thread t = new Thread(r) {
public void run() {
System.out.print(Dog);
}
};
t.start();
What is the result?
Given:
1. public class Threads5 {
2. public static void main (String[] args) {
3. new Thread(new Runnable() {
4. public void run() {
5. System.out.print(bar);
6. }}).start();
7. }
8. }
What is the result?
Given:
1. class X {
2. X() { System.out.print(1); }
3. X(int x) {
4. this(); System.out.print(2);
5. }
6. }
7. public class Y extends X {
8. Y() { super(6); System.out.print(3); }
9. Y(int y) {
10. this(); System.out.println(4);
11. }
12. public static void main(String[] a) { new Y(5); }
13.}
What is the result?
Given:
1. public class A {
2. public void doit() {
3. }
4. public String doit() {
5. return a;
6. }
7. public double doit(int x) {
8. return 1.0;
9. }
10.}
What is the result?
Given:
interface Foo { int bar(); }
public class Sprite {
public int fubar( Foo foo ) { return foo.bar(); }
public void testFoo() {
fubar(
//insert code here 15
);
}
}
Which code, inserted at line 15, allows the class Sprite to compile?
Given:
11. public enum Title {
12. MR(Mr.), MRS(Mrs.), MS(Ms.);
13. private final String title;
14. private Title(String t) { title = t; }
15. public String format(String last, String first) {
16. return title + + first + + last;
17. }
18. }
public static void main(String[] args) {
System.out.println(Title.MR.format(Doe, John));
}
What is the result?
Given the following six method names:
addListener
addMouseListener
setMouseListener
deleteMouseListener
removeMouseListener
registerMouseListener
How many of these method names follow JavaBean Listener naming rules?