They're out of range for the submap, not the original map. The submap only has keys between "b" and "g" (inclusive of "b" but not of "g") because that's how the submap was created.
#5 is OK because even though "r" is outside submap's range from "b" to "g", "r" isn't being added to the submap, but to the main map. That's fine, as the main map has no restrictions. The submap just won't ever show the "r" entry, as it's out of the submap's range.
#6 causes an error because "p" is outside the submap's range, and the code is specifically trying to add the "p" into the submap. That's not allowed, so you get an error.
I agree with Mike. It's simple on line 4 you have made submaps range only from 'b' to 'g'(but actually 'f'). So you can only add keys range of 'b' to 'f'. But you have try to add keys like 'r' and 'p' they are not in the key range of submap. That's why you got that IllegalArgumentExceptions.