File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Javacaps mock exam

 
Neha Sawant
Ranch Hand
Posts: 204
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is from Javacaps mock 1 Q12
Here the answer given is A but since according to our final discussion string literals are not garbage collected then the answer should be D.
Am i right?

String string1 = "Test";
String string2 = "Today";
string1 = null;
string1 = string2;
A) 1
B) 2
C) 3
D) 0
another question no 11
A) The garbage collector runs in low memory situations
B) You can run the garbage collector when ever you want.
C) When it runs, it releases the memory allocated by an object, which is no more in use.
D) Garbage collector immediately runs when you set the references to null.
Ans given is A and C
but i feel it should be only C
Please someone help
Neha

 
Nain Hwu
Ranch Hand
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neha,
I agree with you 100%.
 
Fei Ng
Ranch Hand
Posts: 1244
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree on the first one..
but the second one..
the GC does A) The garbage collector runs in low memory situations
so it is A and C.
correct me if i am wrong.
 
Neha Sawant
Ranch Hand
Posts: 204
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But FEING you cannot be sure when GC occurs so you cannot make a conclusion like the one mentioned
Correct me if i am wrong
Regards
Neha
 
vishal avad
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi neha
u can not sure when GC is going to run but its true that it runs in low memory situations.
but it is not sure that whether it able to free up the memory or not
i m agree on 1.
 
amit mawkin
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Fei

------------------
coffee drinker
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i agree with vishal.
-maulin.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic