Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Sybex OCAJP 8 Online material: StingBuilder question

 
Greenhorn
Posts: 10
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I just came across this question earlier and was racking my brain trying to figure it out. I understand that equals() is not overridden in StringBuilder, so the references are compared and should return false as they're two different objects. So I can't see how this would produce two (after the non-compiling line is removed).



I ran this and commented the third if statement. It didn't produce any output.

Am I missing something?



 
Greenhorn
Posts: 27
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simon, it's clearly a mistake in the test. Notice that in the solutions description it says:

StringBuilder does not implement the equals method, so you cannot compare their values using the equals() either.



I actually have the OCA test scheduled to be taken tomorrow. Hopefully they don't have these kind of mistakes
 
Simon Miller
Greenhorn
Posts: 10
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reassurance Vyacheslav, I was pretty sure it was a mistake after running it but I've had trouble with String/StringBuilder comparisons so I second guessed myself.

Best of luck for tomorrow!  
 
Bartender
Posts: 1248
86
Hibernate jQuery Eclipse IDE Angular Framework Spring MySQL Database AngularJS Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simon Miller,
Welcome to CodeRanch!    will you please QuoteYourSources ? ( Sybex online material Or text book etc )so this thread will be useful for others too, who may face same problem.

Vyacheslav Belenky, best of luck for the exam.
 
Simon Miller
Greenhorn
Posts: 10
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ganesh Patekar wrote:Simon Miller,
Welcome to CodeRanch!    will you please QuoteYourSources ? ( Sybex online material Or text book etc )so this thread will be useful for others too, who may face same problem.

Vyacheslav Belenky, best of luck for the exam.



Thanks for the welcome. The question being referred to is part of the online tool that's bundled with Boyarsky and Selikoff's 'OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808'. It appeared as question 32 in the second 60-question mock exam.
 
Ganesh Patekar
Bartender
Posts: 1248
86
Hibernate jQuery Eclipse IDE Angular Framework Spring MySQL Database AngularJS Tomcat Server Java
 
A day job? In an office? My worst nightmare! Comfort me tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic