Bookmark Topic Watch Topic
  • New Topic

Collection

 
Shiva Mohan
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Report post to moderator
javabeat question

Given two collection objects referenced by c1 and c2, which of these statements are true?

Select 2 correct options

(1) c1.retainAll(c2) will not modify c1
(2) c1.removeAll(c2) will not modify c1
(3) c1.addAll(c2) will return a new collection object, containing elements from both c1 and c2
(4) For: c2.retainAll(c1); c1.containsAll(c2); 2nd statement will return true
(5) For: c2.addAll(c1); c1.retainAll(c2); 2nd statement will have no practical effect on c1

the given answers are 4 and 5? I am not sure all this options in coding way? Please help me to start working on this?Any ideas?
 
Prasad Shindikar
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi sirishaaaa,

whenever we say b2[1][1] = something ;
what the compiler really expects is a 2d-array
so when we say b2[1][1] = b;
we are actually passing a 2d-array reference
the dimensions of the array to which this reference points does not matter
 
Prasad Shindikar
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Report post to moderator
sorry
posted the answer in the wrong topic
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Report post to moderator
Nope, you posted in what you thought was the right topic. There's something strange about this particular thread - probably caused by a UBB software bug.

Closing as a duplicate.
 
    Bookmark Topic Watch Topic
  • New Topic