aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes collection operation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "collection operation" Watch "collection operation" New topic
Author

collection operation

payal sharma
Ranch Hand

Joined: Oct 04, 2000
Posts: 57
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?
Vanitha Sugumaran
Ranch Hand

Joined: Apr 11, 2001
Posts: 356
I think 3 is the correct answer.
April.Johnson
Ranch Hand

Joined: May 02, 2001
Posts: 48
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
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
3 is correct.
contains(),containsAll() checks if the required element/Collection is present in the Collection.
-- Sandeep

<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: collection operation