• 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
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

Sybex 816 Chapter 1 Review Questions Effectively Exasperating

 
Ranch Hand
Posts: 48
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still reeling from the Chapter 1 review questions, another case where I found it hard to stay much under 3 minutes average after feeling I knew the chapter material fairly well.
That is just a comment.
My score was okay, but I really find this frustrating:

Which statements about the final modifier are correct? (Choose all that apply.)
(two other correct answers -- I got both of those) and
B. A variable is effectively final if it is marked final.

I am one of the people who did not rejoice at the introduction of "effectively final" as a concept, as I never found typing the keyword final very arduous and it makes things pretty clear.

I guess I just need to memorize that "effectively final" excludes all variables actually marked final for the exam.

Probably people liked the whole "effectively final" deal because method parameters are often effectively final and it looks weird to mark them as such, maybe.

I think my chagrin stems from the fact that there is never anything you can do with an "effectively final" variable that you can't do with a "final" variable, it does seem that we make that (pointless?) distinction on pages 17 and 18.

Is it actually recommended for certification purposes to consider variables marked final as NOT effectively final?  It feels like "1984".

I guess the distinction between the two definitions is:
1. A variable is effectively final only if it is NOT marked final but could be without breaking compilation.
2. A variable is effectively final if it is marked final or could have that modifier added without breaking compilation.

Definition 2 seems more in the spirit of nearly all of OOAD, polymorphism, etc.

The chapter text was pretty clear, so if the Oracle exam people use definition 1 I will at least not have a hard time remembering it after going thru the wringer.
It definitely feels more like law school than OOPS tho.
 
Ranch Hand
Posts: 416
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jesse Silverman wrote:
1. A variable is effectively final only if it is NOT marked final but could be without breaking compilation.


full stop:  

Effectively final means a local variable is not marked final but whose value does not change
after it is set

Java Fundamentals Sybex (CSG) Chapter First Question/Answer
 
Jesse Silverman
Ranch Hand
Posts: 48
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.  As counter-intuitive as the definition seems, we are on trial on the exams.
I remember the late Supreme Court Justice Bork ruling it was okay to fire someone for whistle-blowing, because only "making a concerted effort to report legal or safety violations could not result in disciplinary action."
The fired employee had reported violations all by himself, nobody else collaborated, therefore "it was not a concerted effort" he was canned, and the court upheld it.

This is less upsetting.

So the following question would yield FALSE, I guess?

"A lambda or local class can make reference to a variable in the surrounding scope only if it is effectively final?"

FALSE: it could also actually be marked final!

Welcome to law school.
 
Marshal
Posts: 71070
292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Charles O'Leary wrote:. . . Java Fundamentals Sybex (CSG) Chapter First Question/Answer

Always check the Java® Language Specification (=JLS). that is the definitive source, and Oracle will use it when setting the questions. It does say,

. . . effectively final if . . .

  • It is not declared final.
  • Note that quote is incomplete and there are other conditions to be fulfilled too. You'll find it from the link.
     
    Jesse Silverman
    Ranch Hand
    Posts: 48
    3
    • Likes 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I re-read the chapter, and they make this distinction time and time again.
    This is a rare case of me reading too hastily and cursorily because I felt I knew those sections very well already -- I don't do that, but I did here.
    I still am not a huge fan of making use of effective final-ness, nor the distinction, compared to say "compile time constant vs. final variables that aren't known at compile time" etc.

    But the book does indeed drum it into you that the two concepts should remain distinct when communicating with Oracle, including most certainly on the exams.

    I'm okay with that now, and that's effectively final.
     
    Charles O'Leary
    Ranch Hand
    Posts: 416
    8
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Jesse Silverman wrote: and that's effectively final.


    I see what you did there  
     
    Campbell Ritchie
    Marshal
    Posts: 71070
    292
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    Jesse Silverman wrote:. . . "A lambda or local class can make reference to a variable in the surrounding scope only if it is effectively final?" . . .

    I hope they would never ask such a question. A question should always have a definite right answer, and other answers should be obviously wrong.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic