posted 20 years ago
This is sample mock exam question:
When Integer object created at line 11 eligible for garbage collection?
10.public Object method1() {
11.Object ob = new Integer(30);
12.Object [] oo = new Object[1];
13.oo[0] = ob;
14.oo = null;
15.ob[0] = null;
16.print 'return 23';
17.}
A. Just after line 13
B. Just after line 14
C. Just after line 15
D. Just after line 16 (as method returns)
Ans given is C.
Actually, this program will not compile because, 1.No main method
2. line no. 16 will produce error.
My question is:
1. In real exam, if main method is not given, should we assume that?
2. If statement like 16 is wrong and program will produce error. So, actually we can not select any option.
3. In real exam, do we need to check errors like { } has correct start and end
4. Do we need to check if ; is added or missed for some statement
It would be nice if some one can tell, what should we do in above two cases in actual Exam?
"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."