Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Ranch Hand
Posts: 32
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.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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
Ranch Hand
Posts: 32
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: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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).
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic