Java Reference
In-Depth Information
7. Suppose we have the following class named GC:
1. import java.util.Date;
2.
3. public class GC {
4. public static void main(String [] args) {
5. Date one = new Date();
6. Date two = new Date();
7. Date three = one;
8. one = null;
9. Date four = one;
10. three = null;
11. two = null;
12. two = new Date();
13. }
14. }
Which of the following statements are true? (Select two answers.)
A. The Date object from line 5 is eligible for garbage collection immediately following
line 8.
B. The Date object from line 5 is eligible for garbage collection immediately following
line 10.
C. The Date object from line 5 is eligible for garbage collection immediately following
line 13.
D. The Date object from line 6 is eligible for garbage collection immediately following
line 11.
E. The Date object from line 6 is eligible for garbage collection immediately following
line 13.
8. What is the output of the following code?
1. private class Squares {
2. public static long square(int x) {
3. long y = x * (long) x;
4. x = -1;
5. return y;
6. }
7.
8. public static void main(String [] args) {
9. int value = 9;
10. long result = square(value);
11. System.out.println(value);
12. }
13. }
Search WWH ::




Custom Search