单项选择题

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.


您可能感兴趣的试卷

你可能感兴趣的试题

2.单项选择题

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;

3.单项选择题

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.

4.多项选择题

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)".


5.单项选择题

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

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

7.单项选择题

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.


8.单项选择题

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.

9.单项选择题

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.

10.单项选择题

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.