Since a PriorityQueue is ordered by the natural order (alphabetical in this case) by default and the head of the queue is "the least element with respect to the specified ordering" (PriorityQueue API), I would have guessed this:
Why [bbb, ddd, ccc, eee] instead of [bbb, ccc, ddd, eee]? Can anyone tell me why line A behaves the way it does?
Is it simply a matter of the elements not being sorted in the collection itself (and as such, not showing up ordered in the toString()), but only being ordered when it comes to the methods that operate on it (peek, poll, etc)?
This class and its iterator implement all of the optional methods of the Collection and Iterator interfaces. The Iterator provided in method iterator() is not guaranteed to traverse the elements of the PriorityQueue in any particular order. If you need ordered traversal, consider using Arrays.sort(pq.toArray()).
Since queues are all about ordering (FIFO, LIFO, who comes next etc) I just had this unfounded suspicion that toString() and even the Iterator would pay attention to that stuff. Judging by what you quoted in the API, that doesn't seem to be the case.