• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide - CH1 q. 20

 
Nil. Hatamova
Greenhorn
Posts: 29
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends
This test confused me . I know about finalize() method not guaranteed to run. finalize() method for any object might run but also it might not run. System.gc() also not guaranteed to run. But the test ( in OCA: Oracle
Certified Associate Java SE 8 Programmer I Study Guide ) didnt take C and F as correct answer. And i dont know what is difference between B and C , also E and F. I selected all these four variants. Right answer is B and E


A. finalize() is guaranteed to be called.
B. finalize() might or might not be called
C. finalize() is guaranteed not to be called.
D. Garbage collection is guaranteed to run.
E. Garbage collection might or might not run.
F. Garbage collection is guaranteed not to run.
G. The code does not compile.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nil. Hatamova wrote:I know about finalize() method not guaranteed to run. finalize() method for any object might run but also it might not run. System.gc() also not guaranteed to run.

You are spot-on! For both the finalize() method and the System.gc() method there is no guarantee this method will be executed. So both methods might run or might not run.

Nil. Hatamova wrote:But the test ( in OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide ) didnt take C and F as correct answer. And i dont know what is difference between B and C , also E and F. I selected all these four variants. Right answer is B and E

The reason why C and F are not a correct answer, is because they are not correct And that's because there is a huge difference between "a method is not guaranteed to run" and "a method is guaranteed not to run". The position of the word "not" is very important in both sentences The first one states what you already knew: you have no idea about if the method runs or it doesn't, the method might run but it might also not run. The second one is the opposite of "a method is guaranteed to run" (mentioned in options A and D which means you are absolutely 100% sure the method will run). So "a method is guaranteed not to run" means you are absolutely 100% sure the method will not run. And that's of course an incorrect statement as well, because you don't know if the method might run or not.

In this topic you'll find also an explanation about this question. Might be useful to read as well.

Hope it helps!
Kind regards,
Roel
 
Nil. Hatamova
Greenhorn
Posts: 29
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Roel, for your explanation.. I hope i will be careful for exam
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nil. Hatamova wrote:I hope i will be careful for exam

That's definitely a requirement if you want to pass the exam (with a good score).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic