• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

collection operation

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following methods return �true� if the Collection object is
modified during the operation?
1.remove(), removeAll() and retainAll()
2.remove(), removeAll(), add(), addAll(), contains(), containsAll()
3.remove(), removeAll(),add(), addAll(), retainAll()
4.remove(), add(), contains()
5.removeAll(), addAll(), containsAll() and retainAll()
6.remove(), removeAll(), add(), addAll(), contains(), containsAll() and
retainAll()
7.None of the above.

Here what is meant by Collection object modified during the operation?
 
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think 3 is the correct answer.
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by payal sharma:
Which of the following methods return �true� if the Collection object is modified during the operation?
<snip>
Here what is meant by Collection object modified during the operation?


I would guess that the question is just looking for the methods that actually change the Collection. In other words, which methods alter what the Collection holds? Once you answer that, you can figure out if those methods return a boolean value.\
From the API, the methods that could change the Collection AND return a boolean value are:
add(), addAll(), remove(), removeAll(), and retainAll()
clear() removes all the elements from the Collection, but does not return a boolean.
contains(), containsAll(), equals(), and isEmpty() all return a boolean, but they're just reporting information about the Collection, not changing anything about the collection.
April
 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
3 is correct.
contains(),containsAll() checks if the required element/Collection is present in the Collection.
-- Sandeep
 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic