单项选择题
public class Pass {
public static void main(String [1 args) {
int x 5;
Pass p = new Pass();
p.doStuff(x);
System.out.print(” main x = “+ x);
}
void doStuff(int x) {
System.out.print(” doStuff x = “+ x++);
}
}
What is the result?()
A. Compilation fails.
B. An exception is thrown at runtime.
C. doStuffx = 6 main x = 6
D. doStuffx = 5 main x = 5
E. doStuffx = 5 main x = 6
F. doStuffx = 6 main x = 5
相关考题
-
单项选择题
23. Object [] myObjects = { 24. new integer(12), 25. new String(”foo”), 26. new integer(5), 27. new Boolean(true) 28. }; 29. Arrays.sort(myObjects); 30. for( int i=0; i31. System.out.print(myObjects[i].toString()); 32. System.out.print(” “); 33. } 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. -
单项选择题
public class Person { private name; public Person(String name) { this.name = name; } public int hashCode() { return 420; } } Which is true?()
A. The time to find the value from HashMap with a Person key depends on the size of the map.
B. Deleting a Person key from a HashMap will delete all map entries for all keys of typePerson.
C. Inserting a second Person object into a HashSet will cause the first Person object to beremoved as a duplicate.
D. The time to determine whether a Person object is contained in a HashSet is constant and does NOT depend on the size of the map. -
单项选择题
WhichManclassproperlyrepresentstherelationship“ManhasabestfriendwhoisaDog”?()
A. class Man extends Dog { }
B. class Man implements Dog { }
C. class Man { private BestFriend dog; }
D. class Man { private Dog bestFriend; }
E. class Man { private Dog}
F. class Man { private BestFriend}
