单项选择题Which statement is true?()

A.A class’s finalize() method CANNOT be invoked explicitly.
B.super.finalize() is called implicitly by any overriding finalize() method.
C.The finalize() method for a given object is called no more than once by the garbage collector.
D.The order in which finalize() is called on two objects is based on the order in which the two objects became finalizable.


您可能感兴趣的试卷

你可能感兴趣的试题

1.多项选择题

Given:

And MainClass exists in the /apps/com/company/application directory. Assume the CLASSPATH
environment variable is set to "." (current directory).
Which two java commands entered at the commandline will run MainClass?()

A.java MainClass if run from the /apps directory
B.java com.company.application.MainClass if run from the /apps directory
C.java -classpath /apps com.company.application.MainClass if run from any directory
D.java -classpath . MainClass if run from the /apps/com/company/application directory
E.java -classpath /apps/com/company/application:. MainClass if run from the /apps directory

2.单项选择题

Given the following directory structure:
bigProject
|--source
||--Utils.java|
|--classes
|--
And the following command line invocation:
javac -d classes source/Utils.java
Assume the current directory is bigProject,what is the result?()

A.If the compile is successful, Utils.class is added to the source directory.
B.The compiler returns an invalid flag error.
C.If the compile is successful, Utils.class is added to the classes directory.
D.If the compile is successful, Utils.class is added to the bigProject directory.

4.单项选择题

Given a class Repetition:

Which code should be inserted at line 1 of Demo.java to compile and run Demo to print "pizzapizza"?()

A.import utils.*;
B.static import utils.*;
C.import utils.Repetition.*;
D.static import utils.Repetition.*;
E.import utils.Repetition.twice();
F.import static utils.Repetition.twice;

5.单项选择题

Given:

What is the result?()

A.Compilation fails due to an error in line 23.
B.Compilation fails due to an error in line 29.
C.A ClassCastException occurs in line 29.
D.A ClassCastException occurs in line 31.
E.The value of all four objects prints in natural order.

6.多项选择题

Given a pre-generics implementation of a method:

What three changes allow the class to be used with generics and avoid an unchecked warning?()

A.Remove line 14.
B.Replace line 14 with "int i = iter.next();".
C.Replace line 13 with "for (int i : intList) {".
D.Replace line 13 with "for (Iterator iter : intList) {".
E.Replace the method declaration with "sum(List intList)".


7.单项选择题

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

8.多项选择题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.

9.单项选择题

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.


10.单项选择题

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.