Home » Oracle » 1z0-804 » What is the result?
Given:
What is the result?
A. peach orange apple
B. peach orange
C. apple orange
D. The program does not compile.
E. The program generates an exception at runtime.
Correct Answer: D
Explanation/Reference:
Explanation:
int compare(T obj1, T obj2)
0 if equal positive if obj1 greater negative if obj2 greater
The compiler has a problem with the line:
public boolean compare(String s1, String s2) {
return s1.length() > s2.length(); error: <anonymous comparetest.CompareTest$1> is not abstract and does not override abstract method compare(String,String) in Comparator new Comparator<String>() {
Error: compare(String,String) in <anonymous comparetest.CompareTest$1> cannot implement compare(T,T) in Comparator public boolean compare(String s1, String s2) { return type boolean is not compatible with int where T is a type-variable:
T extends Object declared in interface Comparator
Download Printable PDF. VALID exam to help you PASS.
|
|