This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Doubt about Chapter 3, Review Question 2 (Java OCA 8 Programmer I Study Guide, Sybex)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I am confused why option D is part of the correct answers in problem set 2 of chapter 3 Review Questions?
 
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
Hi Ntobeko Mdletshe,

First of all, a warm welcome to CodeRanch!

Ntobeko Mdletshe wrote:I am confused why option D is part of the correct answers in problem set 2 of chapter 3 Review Questions?


Because it's actually a correct answer

Have you ever heard of the String Literal (or Constant) Pool? If not, you should definitely read this excellent article. And also carefully re-read the section about String equality on page 117.

Hope it helps!
Kind regards,
Roel
 
Ntobeko Mdletshe
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok this is the sentence that confuse me. Taken directly from Review Answers explanation

Finally, line 8 compares one object from the string pool with one that was explicitly
constructed and returns false.


So if line 8 returns false how come is it correct?
 
Marshal
Posts: 6973
471
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please provide full quiz question as well as possible answers. If someone don't have that book or haven't read it yet, they won't be able to help you (even if they could).
 
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

Ntobeko Mdletshe wrote: Finally, line 8 compares one object from the string pool with one that was explicitly
constructed and returns false.


So if line 8 returns false how come is it correct?


That's a mistake in the study guide, which is already listed on the official errata overview.

Hope it helps!
Kind regards,
Roel
 
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

Liutauras Vilda wrote:Please provide full quiz question as well as possible answers.


I don't think it was required this time, because it's about an already reported errata item; not about a misunderstanding or confusion about some code snippet.
Anyway it's about this question.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!