Given the fully-qualified class names:
com.foo.bar.Dog
com.foo.bar.blatz.Book
com.bar.Car
com.bar.blatz.Sun
Which graph represents the correct directory structure for a JAR file from which those classes can be used by the compiler and JYM?()
A. Jar A
B. Jar B
C. Jar C
D. Jar D
E. Jar E
您可能感兴趣的试卷
你可能感兴趣的试题
A class games.cards.Poker is correctly defined in the jar file Poker.jar.
A user wants to execute the main method of Poker on a UNIX system using the command:
java games.cards.Poker
What allows the user to do this?()
A. put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java
B. put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java/*.jar
C. Put Poker.jar in directory /stuff/java, and set the CLASSPATH to include /stuff/java/Poker.jar
D. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java
E. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuffijava/*.jar
F. put Poker.jar in directory /stuff/java/games/cards, and set the CLASSPATH to include /stuff/java/Poker.jar
1. public class GC {
2. private Object o;
3. private void doSomethingElse(Object obj) { o = obj; }
4. public void doSomething() {
5. Object o = new Object();
6. doSomethingElse(o);
7. o = new Object();
8. doSomethingElse(null);
9.o=null;
10. }
11. }
When the doSomething method is called, after which line does the Object created in line 5 become available for garbage collection?()
A. Line 5
B. Line 6
C. Line 7
D. Line 8
E. Line 9
F. Line 10
11. class Snoochy {
12. Boochybooch;
13. public Snoochy() { booch = new Boochy(this); }
14. }
15.
16. class Boochy {
17. Snoochy snooch;
18. public Boochy(Snoochy s) { snooch = s; }
19. }
And the statements:
21. public static void main(String[] args) {
22. Snoochy snoog = new Snoochy();
23. snoog = null;
24. // more code here
25. }
Which statement is true about the objects referenced by snoog, snooch, and booch immediately after line 23 executes?()
A. None of these objects are eligible for garbage collection.
B. Only the object referenced by booch is eligible for garbage collection.
C. Only the object referenced by snoog is eligible for garbage collection.
D. Only the object referenced by snooch is eligible for garbage collection.
E. The objects referenced by snooch and booch are eligible for garbage collection.
11. rbo = new ReallyBigObject();
12. // more code here
13. rbo = null;
14. /* insert code here */
Which statement should be placed at line 14 to suggest that the virtual machine expend effort toward recycling the memory used by the object rbo?()
A. System.gc();
B. Runtime.gc();
C. System.freeMemory();
D. Runtime.getRuntime().growHeap();
E. Runtime.getRuntime().freeMemory();
11. public void genNumbers() {
12. ArrayList numbers = new ArrayList();
13. for (int i=0; i<10; i++) {
14. int value = i * ((int) Math.random());
15. Integer intObj = new Integer(value);
16. numbers.add(intObj);
17. }
18. System.out.println(numbers);
19. }
Which line of code marks the earliest point that an object referenced by intObj becomes a candidate for garbage collection?()
A. Line 16
B. Line 17
C. Line 18
D. Line 19
E. The object is NOT a candidate for garbage collection.
class Foo {
private int x;
publicFoo(intx) {this.x=x; }
public void setX( int x) { this.x = x; }
public int getX() { return x; }
}
public class Gamma {
static Foo fooBar( Foo foo) {
foo = new Foo( 100);
return foo;
}
public static void main( String[] args) {
Foo foo = new Foo( 300);
System.out.print( foo.getX() + “-“);
Foo fooFoo = fooBar( foo);
System.out.print( foo.getX() + “-“);
System.out.print( fooFoo.getX() + “-“);
foo = fooBar( fooFoo);
System.out.print( foo.getX() + “-“);
System.out.prmt( fooFoo.getX());
}
}
What is the output of this program?()
A. 300-100-100-100-100
B. 300-300-100-100-100
C. 300-300-300-100-100
D. 300-300-300-300-100
10. class Inner {
11. private int x;
12. public void setX( int x) { this.x = x; }
13. public int getX() { return x; }
14. }
15.
16. class Outer {
17. private Inner y;
18. public void setY( Inner y) { this.y = y; }
19. public Inner getY() { return y; }
20. }
21.
22. public class Gamma {
23. public static void main( String[] args) {
24. Outer o = new Outer();
25. Inner i = new Inner();
26.int n=10;
27. i.setX(n);
28. o.setY(i);
29. // insert code here
30. System.out.println( o.getY().getX());
31. }
32. }
Which three code fragments, added individually at line 29, produce the output 100?()
A. n = 100;
B. i.setX( 100);
C. o.getY().setX( 100);
D. i = new Inner(); i.setX( 100);
E. o.setY( i); i = new Inner(); i.setX( 100);
F. i = new Inner(); i.setX( 100); o.setY( i);
public class ItemTest {
private final mt id;
public ItemTest(int id) { this.id = id; }
public void updateId(int newId) { id = newId; }
public static void main(String[] args) {
ItemTest fa = new ItemTest(42);
fa.updateId(69);
System.out.println(fa.id);
}
}
What is the result?()
A. Compilation fails.
B. An exception is thrown at runtime.
C. The attribute id in the Item object remains unchanged.
D. The attribute id in the Item object is modified to the new value.
E. A new Item object is created with the preferred value in the id attribute.
public class Item {
private String desc;
public String getDescription() { return desc; }
public void setDescription(String d) { desc = d; }
public static void modifyDesc(Item item, String desc) {
item = new Item();
item.setDescription(desc);
}
public static void main(String[] args) {
Item it = new Item();
it.setDescription(”Gobstopper”);
Item it2 = new Item();
it2.setDescription(”Fizzylifting”);
modifyDesc(it, “Scrumdiddlyumptious”);
System.out.println(it.getDescription());
System.out.println(it2.getDescription());
}
}
What is the outcome of the code? ()
A. Compilation fails.
B. Gobstopper Fizzylifting
C. Gobstopper Scrumdiddlyumptious
D. Scrumdiddlyumptious Fizzylifltng
E. Scrumdiddlyumptious Scrumdiddlyumptious
11. class Payload {
12. private int weight;
13. public Payload(int wt) { weight = wt; }
13. public void setWeight(mt w) { weight = w; }
15. public String toString { return Integer.toString(weight); }
16. }
17.
18. public class TestPayload {
19. static void changePayload(Payload p) {
20. /* insert code here */
21. }
22.
23. public static void main(String[] args) {
24. Payload p = new Payload();
25. p.setWeight(1024);
26. changePayload(p);
27. System.out.println(”The value of p is “+ p);
28. }
29. }
Which statement, placed at line 20, causes the code to print “The value of p is 420.”?()
A. p.setWeight(420);
B. p.changePayload(420);
C. p = new Payload(420);
D. Payload.setWeight(420);
E. p = Payload.setWeight(420);
F. p = new Payload(); p.setWeight(420);
最新试题
What is the output if the main() method is run?()
Which statement is true?()
What is the result?()
Given that t1 is a reference to a live thread, which is true?()
Which statement is true about the set variable on line 12?()
Given: foo and bar are public references available to many other threads, foo refers to a Thread and bar is an Object. The thread foo is currently executing bar.wait(). From another thread, what provides the most reliable way to ensure that foo will stop executing wait()?()
What is the appropriate definition of the hashCode method in class Person?()
Which two can be results?()
What is the result?()
Which three will compile and run without exception?()