aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes kb 6 book selt test question doubt ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "kb 6 book selt test question doubt ?" Watch "kb 6 book selt test question doubt ?" New topic
Author

kb 6 book selt test question doubt ?

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

Please consider the following snippet of code from the self test questions of kb 6 at page no. 656 , question 12 , chapter collections and generics



according to me the size of subs should be 2, because when the did s.add("c2") , as far as i think c2 does not fall in the range of b and d. but on the contrary book says answer is 3 , because subs will contain [c,c2,d]. the book says "the final add viz s.add("c2") is in range of both the tree sets . i would like to know how is this possible ? what do you mean by range ?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18836
    
  40

gurpeet singh wrote:Please consider the following snippet of code from the self test questions of kb 6 at page no. 656 , question 12 , chapter collections and generics



according to me the size of subs should be 2, because when the did s.add("c2") , as far as i think c2 does not fall in the range of b and d. but on the contrary book says answer is 3 , because subs will contain [c,c2,d]. the book says "the final add viz s.add("c2") is in range of both the tree sets . i would like to know how is this possible ? what do you mean by range ?



The tree set sorts the elements -- so for something to be in range, it has to be greater than the minimum value and less then the maximum value of the range (and since your example has inclusive set to true, if can be equal to the min or max as well).

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: kb 6 book selt test question doubt ?