Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide Chapter 3 Question 19

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Which of the following are true? (Choose all that apply)
A. Two arrays with the same content are equal.
B. Two ArrayLists with the same content are equal.
C. If you call remove(0) using an empty ArrayList object, it will compile successfully.
D. If you call remove(0) using an empty ArrayList object, it will run successfully.
E. None of the above.



The books says B and C are the correct answer.

ArrayList does override equals() and defines it as the same elements in the same order.



About answer B, I think it's wrong.
English is not my first language and I interpret "same content" as "contains the same elements ignoring the order of the elements".
Is my interpretation of "same content" wrong?
 
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
Book's explanation is correct.

Frenkel Smeijers wrote:English is not my first language and I interpret "same content" as "contains the same elements ignoring the order of the elements".


Mine too but I think It's not about what we think but what implementer of the language Or that method says since Java 8 Doc: equlas(Object o) method says

Java 8 Doc: equals(Object o) method of List wrote:In other words, two lists are defined to be equal if they contain the same elements in the same order.

 
and book says the same on page no 133 equals() method.

Is my interpretation of "same content" wrong?

I think yes, at least in this scenario.

 
The City calls upon her steadfast protectors. Now for a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic