• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Collections

 
Aru
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,
Can anyone help me out with this ?
Which of these methods from the Collection interface return the value true if the collection object was actually modified by the call?
a. add()
b. retainAll()
c. containsAll()
d. contains()
e. remove()

Thx in advance.
Aruna
 
chetan nain
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
answer: add(), retain(), retainAll(), and remove()
although contains() and containsAll() also return a boolean value, the point to remember here is that the question asks for methods that return true AFTER modification
HTH
chetan
 
Ada Wang
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add() - Returns true if this collection changed as a result of the call.
retainAll() - Return true if this collection changed as a result of the call
contains() - Returns true if this collection contains the specified element
containsAll() - Returns true if this collection contains all of the elements in the specified collection.
remove() - Returns true if this collection changed as a result of the call
Ada
 
Ada Wang
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer should be ABE.
 
Karthik Subramanian
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I agree with wang.The answer is a,b,e
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a and e
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic