单项选择题

Given:

Which method will complete this class?()

A.public int compareTo(Object o){/*more code here*/}
B.public int compareTo(Score other){/*more code here*/}
C.public int compare(Score s1,Score s2){/*more code here*/}
D.public int compare(Object o1,Object o2){/*more code here*/}


您可能感兴趣的试卷

你可能感兴趣的试题

1.多项选择题Which two statements are true about the hashCode method?()

A.The hashCode method for a given class can be used to test for object equality and object inequality for that class.
B.The hashCode method is used by the java.util.SortedSet collection class to order the elements within that set.
C.The hashCode method for a given class can be used to test for object inequality, but NOT objecte quality, for that class.
D.The only important characteristic of the values returned by a hashCode method is that the distribution of values must follow a Gaussian distribution.
E.The hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for swift retrieval.

2.单项选择题

Given:

Which statement is true?()

A.The equals method does NOT properly override the Object.equals method.
B.Compilation fails because the private attribute p.name cannot be accessed in line 5.
C.To work correctly with hash-based data structures,this class must also implement the hashCode method.
D.When adding Person objects to a java.util.Set collection,the equals method in line 4 will prevent duplicates.


3.单项选择题

Given:

What is the result?()

A.The value "4" is printed at the command line.
B.Compilation fails because of an error in line 5.
C.Compilation fails because of an error in line 9.
D.A NullPointerException occurs at runtime.
E.A NumberFormatException occurs at runtime.
F.An IllegalStateException occurs at runtime.

4.单项选择题

Given:

What is the result?()

A.Compilation fails.
B.pi is bigger than 3.
C.An exception occurs at runtime.
D.pi is bigger than 3. Have a nice day.
E.pi is not bigger than 3. Have a nice day.

5.单项选择题

Click the Exhibit button.

Given:

Which statement is true if a TestException is thrown on line 3 of class B?()

A.Line 33 must be called within a try block.
B.The exception thrown by method 1 in class A is not required to be caught.
C.The method declared on line 31 must be declared to throw a runtime exception.
D.On line 5 of class A,the call to method 2 of class B does not need to be placed in a try catch block.

6.单项选择题

Given:

If class Donkey is invoked twice, the first time without assertions enabled,and the second time with assertions enabled, what are the results?()

A.no output
B.no outputassert is on
C.assert is on
D.no outputAn AssertionError is thrown.
E.assert is onAn AssertionError is thrown.

7.单项选择题

Given:

What is the result?()

A.5,6
B.5,5
C.6,5
D.6,6

8.多项选择题

Given:

Under which three circumstances will the code on line 37 be executed?()

A.The instance gets garbage collected.
B.The code on line 33 throws an exception.
C.The code on line 35 throws an exception.
D.The code on line 31 throws an exception.
E.The code on line 33 executes successfully.

10.单项选择题

Given:

What is the result?()

A.test end
B.Compilation fails.
C.test runtime end
D.test exception end
E.A Throwable is thrown by main at runtime.

最新试题

Given:When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?()

题型:单项选择题

Given a method that must ensure that its parameter is not null:What, inserted at line 12, is the appropriate way to handle a null value?()

题型:单项选择题

Given a class whose instances, when found in a collection of objects, are sorted by using the compare To method, which two statements are true?()

题型:多项选择题

Given:A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key?()

题型:多项选择题

Click the Exhibit buttonWhich two statements are true if a NullPointerException is thrown on line 3 of class C?()

题型:多项选择题

Given:What is the result?()

题型:单项选择题

Given:What is the appropriate definition of the hashCode method in class Person?()

题型:单项选择题

Given:Which command-line invocations will compile?()

题型:单项选择题

Given:What is the result?()

题型:单项选择题

A team of programmers is involved in reviewing a proposed design for a new utility class. After some discussion, they realize that the current design allows other classes to access methods in the utility class that should be accessible only to methods within the utility class itself.What design issue has the team discovered?()

题型:单项选择题