A programmer must create a generic class MinMax and the type parameter of MinMax must implement Comparable. Which implementation of MinMax will compile?
Given:
1. import java.util.*;
2. public class Example {
3. public static void main(String[] args) {
4. // insert code here
5. set.add(new Integer(2));
6. set.add(new Integer(1));
7. System.out.println(set);
8. }
9. }
Which code, inserted at line 4, guarantees that this program will output [1, 2]?
Given:
1.
2.
3.
4.
5. class A {
6. void foo() throws Exception { throw new Exception(); }
7. }
8. class SubB2 extends A {
9. void foo() { System.out.println("B "); }
10.}
11.class Tester {
12. public static void main(String[] args) {
13. A a = new SubB2();
14. a.foo();
15. }
16.}
What is the result?
Given:
try {
ResourceConnection con = resourceFactory.getConnection();
Results r = con.query("GET INFO FROM CUSTOMER"); // Linea 86
info = r.getData(); 88. con.close();
} catch (ResourceException re) {
errorLog.write(re.getMessage());
}
return info;
Which statement is true if a ResourceException is thrown on line 86?
public class Breaker {
static String o = ;
public static void main(String[] args) {
z: o = o + 2;
for (int x = 3; x < 8; x++) {
if (x == 4)
break;
if (x == 6)
break z;
o = o + x;
}
System.out.println(o);
}
}
What is the result?
Given:
public void testIfA() {
if (testIfB(True)) { //Linea 12
System.out.println(True);
} else {
System.out.println(Not true);
}
}
public Boolean testIfB(String str) {
return Boolean.valueOf(str); //Linea 19
}
What is the result when method testIfA is invoked?